c# - 为什么来自 PCL 项目的 DLL 是 x86 程序集?

标签 c# visual-studio-2012 visual-studio-2013 silverlight-5.0 portable-class-library

我在 Visual Studio 2012 中有一个 C# 项目,它是一个 PCL,针对这些平台(我删除了名称):

enter image description here

当我尝试将 dll 从成功构建添加到 VS2013 中的 Silverlight 5 项目时,我收到此警告并且它似乎并没有真正被添加:

Warning 1 There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "[Name]", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.

enter image description here

为什么 PCL 会显示为 x86?

最佳答案

当您有一个用于多个目标的 PCL 项目并且您想要在其他项目中引用输出 .dll 时,请确保您选择了具有正确编译的正确 .dll。

例如:

  • 您有一个商业项目,它是适用于 WP 8 和 SL 5 的 PCL。
  • 您有 2 个项目引用上述业务项目的 dll
    • SL项目
    • WP 8 项目

在 WindowsPhone 项目中,当你去添加引用时,你应该选择为 ARM 编译的那个 [注意,如果你想在模拟器上运行,你应该选择 x86 版本,因为模拟器不是 ARM]。如果您添加 x86 版本并在配置管理器中将其设置为 ARM,Visual Studio 将警告您出现相同的错误,因为您将运行 ARM 代码并引用 x86 代码。

检查您添加的.dll 是否与配置管理器匹配。将其更改为您想要的正确架构,而不是“多平台”与“任何 CPU”

关于c# - 为什么来自 PCL 项目的 DLL 是 x86 程序集?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26244174/

相关文章:

c++ - 条件预处理难题

c# - File.Delete() 在程序完成之前不删除文件

c# - 看不到 system.io.ports

函数调用后无法定义变量

c# - 即使没有空检查,使用 "as"而不是强制转换是否有意义?

无法在 Windows 7 x64 上编译 C

c# - 如何让 VS2013 中的 CodeMap 针对 SQL Server 2014 Express 实例运行?

c++ - 移植项目VS2003 -> VS2013错误C2039 serialize is not member of hash_Map

c# - 系统图标 - Windows 10 风格

c# - Mono 上的垃圾收集最坏情况性能