开发者

Building web sites for AnyCpu

I have a .Net 3.5 web site project which I am developing in VS2010 (recently moved form VS2008) and building/deploying with MSBuild and TeamCity. I am using Msbuild tools version 3.5. The web site project communicates with a couple of COM components via Interop-dlls. As I understand, these interops are generated by Visual Studio as a wrapper for the COM component. My problem is that when the application is built and deployed u开发者_如何学Csing Microsoft.WebDeployments.targets I get a runtime error message saying:

Could not load file or assembly 'Interop.cvvToolkitLib' or one of its dependencies. An attempt was made to load a program with an incorrect format.

After googling for similar problems I have found alot of posts saying that building for "AnyCpu" should fix this problem, since the tool that is generating the interops defaults to x86.

So I opened my build script and tried to specify the platform as AnyCpu:

<Platform>AnyCPU</Platform>

Still same problem. More googling hinted that it might be "AnyCpu" or "Any CPU" instead, so I tried both. Still no luck. Other forum posts suggested something like this instead:

<ItemGroup>
    <ConfigurationToBuild Include="Release|Any CPU">
      <FlavorToBuild>Release</FlavorToBuild>
      <PlatformToBuild>Any CPU</PlatformToBuild>
    </ConfigurationToBuild>
  </ItemGroup>

or

<PlatformTarget>AnyCPU</PlatformTarget>

The error remains the same. So my question to you stackoverflowers is: Am I doing something wrong in trying to make the web site build for Any CPU, or is the solution maybe lying somewhere else? Do I have to explicitly pass some arguments in to the <CallTarget Targets="Build"/> ?

I am not very experienced with MSbuild, so I may overlook something important. I have other web applications (not web sites) that are communicating with the same COM components without any issues, so it's only a problem for the web sites. The web applications are build like this:

<MSBuild
      Projects="$(ProjectFile)"
      StopOnFirstFailure="true"
      Targets="ResolveReferences;_CopyWebApplication;_BuiltWebOutputGroupOutput"
      Properties="...Platform=AnyCPU..." />

Here I pass the Platform as a property, so I am just guessing I need something similar for the web sites.


The problem was solved by using the 3.5 version of MSbuild. I was using the 4.0 version with 3.5 toolsversion. For some reason that caused the interop dlls to be built on the wrong platform. I have however no idea why it was causing this issue. I have been seeing several strange issues with using MSbuild 4.0 for 3.5-projects. If anyone can enlighten me to why these things happen, I will be happy.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜