9

我正在尝试使用 Chilkat library 编译(使用Visual Studio 一个ASP.Net 网站。由于此错误,编译失败:

无法加载文件或程序集 'ChilkatDotNet2, Version=9.0.8.0, Culture=neutral, PublicKeyToken=eb5fc1fc52ef09bd' 或其依赖项之一。试图加载格式不正确的程序。

我被告知由于平台不合规而发生此错误。

奇怪的是,虽然编译失败,但网站一旦从浏览器访问就可以工作。我的理论是IIS编译使用 Framework64(64 位)文件夹中的 csc.exe 编译器,而Visual Studio使用 Framework(32 位)文件夹中的 csc.exe 编译器。如果确实如此,我如何配置我的 Visual Studio 以使用 64 位编译器运行 ASP.Net 站点?

这是我目前的开发配置:

  • 视窗 7 (x64)。
  • Visual Studio 2008 Pro(当然是 x86 ......)。
  • Chilkat 库 (x64)
  • IIS/Asp.net (x64)。
4

2 回答 2

27

The Why:
Your website (the managed portion, likely all of it non-third party) isn't compiled in 32 or 64-bit mode, at least not in the way you're thinking. The difference is thatWebDevServer.exe (A version of Cassini) that visual studio uses for it's webserver is exclusively 32-bit. So, it only loads 32-bit compatible DLLs.

IIS on a 64 bit machine can run in either 32 or 64 bit mode (defaults to 64-bit), depending on the configuration settings, so it has no trouble loading up your application.

Solution: Unfortunately, there aren't a lot of options here, I asked the same question a while ago. Your best bet is to use IIS for debugging. You set it up like this:

  • Web Project > Settings
  • "Web" Tab
  • Under Servers, select Use Local IIS Web Server
于 2010-04-08T00:06:14.340 回答
0

解决方案是将两个 DLL(x64 和 x86 DLL)都放在 GAC 中,让每个应用程序动态决定何时使用 x64 或 x86 DLL(当然,您必须在项目中引用 GAC DLL)。

我亲自与 ChilkatDotNet2 的开发人员讨论过,这是我们都同意的解决方案。

于 2011-12-30T19:34:39.910 回答