6

I have a C# project in Visual Studio 2012 that is a PCL, targeting these platforms (I removed the names):

enter image description here

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:

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

Why would a PCL be showing as x86?

Christopher Currens
  • 29,917
  • 5
  • 57
  • 77
Jake
  • 3,411
  • 4
  • 21
  • 37
  • 4
    Your warning is tiny, please copy/paste the error message into your question body – eddie_cat Oct 07 '14 at 19:57
  • 2
    eddie_cat, I added it, although you can also right click on the image and View Image (in Firefox at least). – Jake Oct 07 '14 at 20:01
  • 1
    I don't think it's normal for your Configuration and Platform to be N/A. Try creating a new Configuration with the AnyCPU setting. – Theodoros Chatzigiannakis Oct 07 '14 at 20:07
  • 1
    Theodoros, under the Build tab it does say Platform: Active (Any CPU). I don't know how to create a new configuration. – Jake Oct 07 '14 at 20:10
  • 1
    @Jake My mistake, then. – Theodoros Chatzigiannakis Oct 07 '14 at 20:11
  • Its meaning not your project/solution, but whatever the reference is (you have removed the name in the picture, and changed it to [Name] in the text). It is saying that this reference is built to x86. Do you have the source of said reference, i.e. to build it to AnyCPU. Also it is standard to have N/A in configuration and namespace under the Application tab of properties if the project in question is not a directly runnable application (i.e. not an .exe). If you don't have the source, then building your solution to x86 should remove this error, although that may not be what you want.. – OJay Oct 07 '14 at 20:31
  • OJay, sorry for the confusion. The reference is to the project in the first screenshot. I have built this reference with a PCL and am trying to add it to a Silverlight project. – Jake Oct 07 '14 at 20:34
  • It is. It's listed as "Active (Any CPU)" – Jake Oct 07 '14 at 20:36
  • There is also a build target drop down ( alittle bit further down), does this also say Any CPU – OJay Oct 07 '14 at 20:37
  • Is this in the build tab? I don't see such: http://i.imgur.com/Xg0btSX.png – Jake Oct 07 '14 at 20:40
  • I don't have the VS version anymore that can select these targets. But you are setting them very low, there was never a 64-bit version of Silverlight v4 for example. Probably has something to do with it. The warning is benign, you can suppress it by explicitly if you really want to by targeting x86 in your EXE project. Right-click the project, Properties, Build tab. – Hans Passant Oct 07 '14 at 20:42
  • @HansPassant: What EXE project? He has a portable class library project, and a silverlight project. No EXE. – Ben Voigt Oct 07 '14 at 20:54
  • Yes that is the build tab and interesting that your target platform box is grayed out. Not sure what configuration would cause this. The only other place I would check would be under the configuration manager of the solution (not the properties of the projects) i.e. Right Click the solution and choose configuration manager. – OJay Oct 07 '14 at 21:01
  • @Jake: "Platform target" is there in your screenshot, but greyed out. – Ben Voigt Oct 26 '14 at 19:27

1 Answers1

0

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.

For example:

  • you have a Business project that is PCL for WP 8 and SL 5.
  • you have 2 projects that reference the dll from the above business project
    • SL proj
    • WP 8 proj

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]. 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.

Check if the .dll that you add match with the configuration manager. Change it for the right architecture that you want instead of "Multiple platforms" vs "Any CPU"

user1845593
  • 1,736
  • 3
  • 20
  • 37