I have an ASP.NET MVC 3 .NET application under Visual web developer Express 2010.
By default it is build as 'Any CPU'. When tested, Environment.Is64BitProcess always returns false (I have Windows 7 64 bit). I tried Stack Overflow question Change target CPU settings in Visual Studio 2010 Express for both x86 and x64, but it always results in an error, something along the lines of:
Cannot load type 'MyApp.UI.MvcApplication'.
and points to the global.asax
file with only one line:
<%@ Application Codebehind="Global.asax.cs" Inherits="MyApp.UI.MvcApplication" Language="C#" %>
How could I fix it?
This all depends on what process is hosting your website.
If you are using Cassini or IIS Express, it will always be a 32-bit application because those processes are always 32-bit.
If you are using IIS, then it depends on what your AppPool is set to.
The CPU settings affect what it can run under, not what it should.
These settings are more typical when you have different assemblies for different platforms, say if they have very specific platform invoke for each. Or if you have a stand alone executable that you want to always run 32-bit, even on a 64-bit environment. Generally, for ASP.NET you want your assemblies to to be Any CPU and use IIS's configuration to decide if you are going to use a 32-bit or 64-bit AppPool.
For IIS 7+, you would look under the Advanced Settings of the App Pool. Set Enabled 32-bit applications
to True
for 32-bit, or False
for 64-bit.
If you website is running on IIS Express or Cassini, then you don't have a choice.