8

I have a VS2012 solution that can be simplified as follows: An asp.net mvc 4 web app, a middle c# class library project, and an end c# library project for calculations etc.

The web app currently has no references to the other projects and is configured to 'Any CPU' when building. The end project is x64. I now want to join the web app to the end project via the middle project, but I understandable get architecture type errors when trying to reference the middle x64 project from the web app. If I set the web app to x64 I also get the same type of error.

The web app will run on and x64 server and so I think the easiest thing to do would be to set the web app to x64 but I believe it might be case that you cannot retrospectively change it i.e. it needs to be created as x64.

My question is Can I convert the existing web app to x64? If not, how do I create a x64 web app (I could not see any option) EDIT: Even when I set up a new mvc 4 project, change the build setting to x64 I still get this problem.

You'll be surprised to hear that I am very new to software development, and although build errors between x86 and x64 seem intuitive I don't really understand why. There are many posts it seems on this topic with answers being 'change all projects to Any Cpu, but I am constrained to keeping the end project as x64.

I'm using Windows 8 and IIS 8.

For reference, the build warning I get when adding a reference for the middle project to the web app is:

Warning 1 There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference C:\MyPath\Sln\MiddleProject\bin\x64\Debug\MiddleProject.dll", "AMD64". 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.

Erik Philips
  • 53,428
  • 11
  • 128
  • 150
R Swasey
  • 307
  • 3
  • 7
  • @Aaron, the Middle project can be with 64 or 32 but the End project needs to 64. My first approach was to leave the web app and Middle project as Any Cpu, but I still run into the same problem when referencing the End project from the Middle one. – R Swasey Sep 19 '13 at 13:32
  • If you set all 3 projects to x64 you shouldn't have any problem compiling. However, depending on how you have your references configured in Visual Studio you may have problems. Do you have the references configured as file references or project references? – Aaron Carlson Sep 19 '13 at 13:35
  • I'm using project references throughout. I've tried setting all projects to x64 without any luck. I've also tried a number combinations. It's the web app that I just can't get running in x64. I even tried on a 64 bit laptop with no luck (i.e. create new app, change to x64 and run.) I've been through many of the IIS files looking for a reference to x86 or 32Bit but no luck there. It's IIS Express by the way, just in case.... – R Swasey Sep 19 '13 at 13:44
  • Should you be able to simply create a new Mvc 4 app and build for x64? Or perhaps I needed to configure IIS Express first? – R Swasey Sep 19 '13 at 13:46
  • 1
    Ok. So you're getting the compile time warning and thinking that's leading to your runtime problems. Really what you need to do is get IIS Express to run as a 64bit process. The warning is relevant but likely not the cause of your runtime problems. I'm not familar with IIS Express but I found these links [link1](http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/3254745-allow-for-iis-express-64-bit-to-run-from-visual-st) [link2](http://stackoverflow.com/questions/10202047/cant-get-iis-express-8-beta-to-run-website-as-64-bit-process) that should help you. – Aaron Carlson Sep 19 '13 at 13:48
  • Ah, these links look very promising. I've will try them out later on and update this post. Many thanks. – R Swasey Sep 19 '13 at 13:56
  • Many thanks Aaron I'm very grateful. Adding in the dword to registry as per your link did indeed fix this issue. (I'm quite sure how to mark a comment as an answer though) – R Swasey Sep 19 '13 at 16:50

2 Answers2

32

It took me a lot of digging on this same problem to find the answer. It turns out you need to get IIS Express to run as a 64 bit process. How do you do that?

Change this in VS: Tools | Options | Projects and Solutions | Web Projects | Use the 64 bit version of IIS Express

I hope that helps resolve your issue.

BrianLegg
  • 1,658
  • 3
  • 21
  • 36
0

Right click on "Project -> Properties -> Build" and change the platform target to the architecture you want.