C# 网站:MSB3270:处理器架构之间存在不匹配
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11690804/
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
Web Site: MSB3270: There was a mismatch between the processor architecture
提问by Sam Leach
I have a Web Forms Web Site project. This web site references 4 class library projects. 3 of these class libraries reference a third-party assembly. I am getting the following compiler error for each of the 3 class library projects.
我有一个 Web 窗体网站项目。该网站引用了 4 个类库项目。其中 3 个类库引用了第三方程序集。对于 3 个类库项目中的每一个,我都收到以下编译器错误。
ASPNETCOMPILER : error ASPCONFIG: Could not load file or assembly 'myAssembly' or one of its dependencies. An attempt was made to load a program with an incorrect format. [Project. metaproj]
ASPNETCOMPILER:错误 ASPCONFIG:无法加载文件或程序集“myAssembly”或其依赖项之一。试图加载格式不正确的程序。[项目。元项目]
I have tried all possible combinations of AnyCPU/x86/x64 on the class library projects. I cannot change this on the Web Site project. I have both a x86 and x64 version of the third-party dll. Tried both.
我已经在类库项目中尝试了 AnyCPU/x86/x64 的所有可能组合。我无法在网站项目上更改此设置。我有第三方 dll 的 x86 和 x64 版本。两个都试了。
"ClassLibrary.csproj" (default target) (4) -> (ResolveAssemblyReferences target) -> C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1561,5 ): warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "ThirdPartyDll, Version=xxx, Culture=neutral, processorArchitectu re=x86", "x86". This mismatch may cause runtime failures. Please consider chang ing the targeted processor architecture of your project through the Configurati on Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture th at matches the targeted processor architecture of your project. [ClassLibrary.cspro j]
“ClassLibrary.csproj”(默认目标)(4)->(ResolveAssemblyReferences 目标)-> C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1561,5):警告 MSB3270:有正在构建的项目的处理器架构“MSIL”与参考的处理器架构“ThirdPartyDll, Version=xxx, Culture=neutral, processorArchitecture re=x86”, “x86”之间不匹配。这种不匹配可能会导致运行时失败。请考虑通过配置管理器更改项目的目标处理器架构,以便在您的项目和参考之间对齐处理器架构,或者依赖于具有与您项目的目标处理器架构相匹配的处理器架构的引用。[ClassLibrary.cspro j]
The bellow illustrates the solution configuration. Note I cannot change from "AnyCPU" here, only from within each individual class library project.
下图说明了解决方案配置。注意我不能从这里的“AnyCPU”更改,只能从每个单独的类库项目中更改。


All .NET 4
所有 .NET 4
Converting the Web Site to a Web Application is not an option.
将网站转换为 Web 应用程序不是一种选择。
Thanks,
谢谢,
采纳答案by Codo
Obviously, you have a native 32 bit DLL. So the application pool on IIS must be configured to run the .NET framework in 32 bit mode.
显然,您有一个本机 32 位 DLL。因此必须将 IIS 上的应用程序池配置为在 32 位模式下运行 .NET 框架。
This can be configured in the IIS Manager. Go to "Application Pool", select the relevant application pool and open the "Advanced Settings..." dialog. The 32 bit option is close to the top.
这可以在 IIS 管理器中配置。转到“应用程序池”,选择相关应用程序池并打开“高级设置...”对话框。32 位选项接近顶部。
回答by Ivan Zlatev
One of your referenced assemblies is x86 only and thus the project chain that references it must be build for x86 only. Make also sure that when you deploy your application pool is configured for 32bit.
您引用的程序集之一仅适用于 x86,因此引用它的项目链必须仅针对 x86 构建。还要确保在部署应用程序池时配置为 32 位。

