开发者

MSBuild: TlbImp error since upgrading to VS 2010

since upgrading 开发者_运维问答my project to VS2010, including the use of MSBuild v4 instead of 3.5 (and not making any other changes), I get the following build error and have no clue how to fix it (log from CC.NET):

  <target name="ResolveComReferences" success="false">
   <message level="high"><![CDATA[C:\Programme\Microsoft SDKs\Windows\v7.0A\bin\TlbImp.exe c:\Assemblies\NMSDVDXU.dll /namespace:NMSDVDXLib /machine:X64 /out:obj\x64\Release\Interop.NMSDVDXLib.dll /sysarray /transform:DispRet /reference:c:\Assemblies\Bass.Net.dll /reference:c:\Assemblies\LogicNP.FileView.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Design.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Management.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /reference:C:\WINDOWS\assembly\GAC\stdole\7.0.3300.0__b03f5f7f11d50a3a\stdole.dll ]]></message>
   <error code="TI0000" file="TlbImp"><![CDATA[A single valid machine type compatible with the input type library must be specified.]]></error>
   <warning code="MSB3283" file="C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets" line="1558" column="9"><![CDATA[Die Wrapperassembly für die Typbibliothek "NMSDVDXLib" wurde nicht gefunden.]]></warning>
   <message level="high"><![CDATA[C:\Programme\Microsoft SDKs\Windows\v7.0A\bin\TlbImp.exe c:\Assemblies\StarBurnX12.dll /namespace:RocketDivision.StarBurnX /machine:X64 /out:obj\x64\Release\Interop.RocketDivision.StarBurnX.dll /sysarray /transform:DispRet /reference:c:\Assemblies\Bass.Net.dll /reference:c:\Assemblies\LogicNP.FileView.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Design.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Management.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /reference:C:\WINDOWS\assembly\GAC\stdole\7.0.3300.0__b03f5f7f11d50a3a\stdole.dll ]]></message>
   <error code="TI0000" file="TlbImp"><![CDATA[A single valid machine type compatible with the input type library must be specified.]]></error>
   <warning code="MSB3283" file="C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets" line="1558" column="9"><![CDATA[Die Wrapperassembly für die Typbibliothek "RocketDivision.StarBurnX" wurde nicht gefunden.]]></warning>
  </target>

Problem: A single valid machine type compatible with the input type library must be specified.

It only applies to the x64 build of my project, x86 still works fine. Apparently, it tries to build a x64 interop assembly from the x86 DLL located in "C:\Assemblies". When executing the TlbImp command with the x64 DLL which is located in a different directory, it works fine. However, I don't know how I can configure my project to use different COM references for the x86 and x64 build. The OS on which the project is being compiled is WinXP x86. Building worked fine when using VS2005 + MSBuild 3.5

Any help would be highly appreciated.

I tried building the upgraded project with MSBuild v3.5, but that doesn't work either. It complains about unknown NoWarn codes (probably new in 4.0).


We had a similar problem with com references for x64 (but different error message), and it turned out that the AnyCPU was missing on the project file (similar to Adam Driscoll's comment). This meant that the x86 interop was being used for both x86 abd x64 builds.

In the csproj file, add this node under each node. When the project is built, the platform independant interop is created/used.


I finally came up with the "solution". As pointed out on MS Connect, the change in x64 build behaviour was intentional apparently. As of VS2010 and later, an x64 build system is required for an x64 build of your application, so I was forced to upgrade my build system to x64 (which basically means reinstalling everything). Then, for the x64 build, you have to use the x64 version of MSBuild, which is located in the "Framework64" folder (more details on the Visual Studio blog: Building on Cross targeting scenarios and 64-bit MSBuild).


It may be due to an issue with your project where the platform target node is missing: Visual Studio 2010 64-bit COM Interop Issue

Not quite sure if this is the same issue...


I think you'll find this is because the targetted assembly must be compiled for the same cpu type as the project build.

Have you considered having 2 projects that contain the same files then refer to the x64 / x86 versions of your target assembly in them?

It may mean having 2 instances of VS open but at least all you need to do is edit then switch and build.

The issue may also be because you are trying to build 64 bit code on a 32bit OS ... I don't think so though, only running the code would be an issue as far as i'm aware.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜