简体   繁体   English

为什么PCL项目中的DLL是x86程序集?

[英]Why is the DLL from a PCL project an x86 assembly?

I have a C# project in Visual Studio 2012 that is a PCL, targeting these platforms (I removed the names): 我在Visual Studio 2012中有一个C#项目是PCL,针对这些平台(我删除了名称):

在此输入图像描述

When I try to add the dll, from a successful build, to a Silverlight 5 project in VS2013, I am getting this warning and it doesn't seem to actually be added: 当我尝试将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". 警告1正在构建的项目的处理器体系结构“MSIL”与参考“[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. 请考虑通过Configuration Manager更改项目的目标处理器体系结构,以便在项目和引用之间调整处理器体系结构,或者依赖于具有与项目的目标处理器体系结构相匹配的处理器体系结构的引用。

在此输入图像描述

Why would a PCL be showing as x86? 为什么PCL会显示为x86?

When you have a PCL project for multiple targets and you want to referene the output .dll in other projects, be sure that you pick the right .dll with the right compilation. 如果您有一个用于多个目标的PCL项目,并且想要在其他项目中引用输出.dll,请确保选择正确编译的正确.dll。

For example: 例如:

  • you have a Business project that is PCL for WP 8 and SL 5. 你有一个商业项目,是WP 8和SL 5的PCL。
  • you have 2 projects that reference the dll from the above business project 您有2个项目引用上述业务项目中的dll
    • SL proj SL proj
    • WP 8 proj WP 8项目

In the WindowsPhone proj When you go to add reference you should pick the one that was compiled for ARM [note that if you want to run on the emulator you should pick the x86 version, because the emulator is not ARM]. 在WindowsPhone项目中当你去添加引用时,你应该选择为ARM编译的那个[注意,如果你想在模拟器上运行,你应该选择x86版本,因为模拟器不是ARM]。 If you add the x86 version and in the configuration manager you set it to ARM, Visual Studio will warn you with that same error that you have, because you will run a ARM code and have a x86 code referenced. 如果添加x86版本并在配置管理器中将其设置为ARM,Visual Studio将使用您所遇到的相同错误警告您,因为您将运行ARM代码并引用x86代码。

Check if the .dll that you add match with the configuration manager. 检查您添加的.dll是否与配置管理器匹配。 Change it for the right architecture that you want instead of "Multiple platforms" vs "Any CPU" 将其更改为您想要的正确架构,而不是“多个平台”与“任何CPU”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM