visual-studio 如何编译x64 asp.net网站?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/2596692/
Warning: these are provided under cc-by-sa 4.0 license.  You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to compile x64 asp.net website?
提问by Nick Craver
I'm trying to compile (using Visual Studio) an ASP.Net websitewith the Chilkat library. The compilation fails due to this error:
我试图编译(使用Visual Studio中)的ASP.Net网站与奇尔卡特库。由于此错误,编译失败:
Could not load file or assembly 'ChilkatDotNet2, Version=9.0.8.0, Culture=neutral, PublicKeyToken=eb5fc1fc52ef09bd' or one of its dependencies. An attempt was made to load a program with an incorrect format.
无法加载文件或程序集“ChilkatDotNet2,版本=9.0.8.0,Culture=neutral,PublicKeyToken=eb5fc1fc52ef09bd”或其依赖项之一。试图加载格式不正确的程序。
I've been told that this error occurs because of platform noncompliance.
有人告诉我,这个错误是由于平台不合规而发生的。
The weird thing is that although the compilation fails, the site works once accessed from a browser. My theory is that the IIScompilation uses csc.exe compiler from the Framework64 (64 bit) folder while the Visual Studiouses csc.exe compiler from the Framework (32 bit) folder. If this is acually it, how can I configure my Visual studio to run with the 64 bit compiler for ASP.Net sites?
奇怪的是,虽然编译失败,但该站点一旦从浏览器访问就可以工作。我的理论是IIS编译使用来自 Framework64(64 位)文件夹的csc.exe 编译器,而Visual Studio使用来自 Framework(32 位)文件夹的 csc.exe 编译器。如果确实如此,我如何配置我的 Visual Studio 以使用 ASP.Net 站点的 64 位编译器运行?
This is my current development configuration:
这是我当前的开发配置:
- Windows 7 (x64).
- Visual Studio 2008 Pro (x86 of course...).
- Chilkat library (x64)
- IIS/Asp.net (x64).
- Windows 7 (x64)。
- Visual Studio 2008 Pro(当然是 x86...)。
- Chilkat 库 (x64)
- IIS/Asp.net (x64)。
回答by Nick Craver
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.
原因:
您的网站(托管部分,可能都是非第三方的)不是以 32 位或 64 位模式编译的,至少不是您想的那样。不同之处在于,visual studio 用于其网络服务器的WebDevServer.exe(Cassini 的一个版本)仅为 32 位。因此,它只加载 32 位兼容的 DLL。
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.
64 位机器上的 IIS 可以在 32 位或 64 位模式下运行(默认为 64 位),具体取决于配置设置,因此加载应用程序没有问题。
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:
解决方案:不幸的是,这里没有很多选择,我前一阵子问了同样的问题。最好的办法是使用 IIS 进行调试。你这样设置:
- Web Project > Settings
- "Web" Tab
- Under Servers, select Use Local IIS Web Server
- 网络项目 > 设置
- “网络”选项卡
- 在服务器下,选择使用本地 IIS Web 服务器
回答by Nick Craver
The solution is to put both of the DLLs (the x64 & x86 DLLs) in the GAC and let each application dynamically decide when to use the x64 or x86 DLL (of course you'll have to reference the GAC DLL in your project).
解决方案是将两个 DLL(x64 和 x86 DLL)放在 GAC 中,让每个应用程序动态决定何时使用 x64 或 x86 DLL(当然,您必须在项目中引用 GAC DLL)。
I've personally discussed with ChilkatDotNet2's developer and this is a solution we both agreed on.
我亲自与 ChilkatDotNet2 的开发人员讨论过,这是我们都同意的解决方案。

