1

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?

Community
  • 1
  • 1
trakos
  • 841
  • 8
  • 25

1 Answers1

2

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.

  • Any CPU means that the assembly is capable of running as 64-bit or 32-bit.
  • x86 means it can only run in a 32-bit process.
  • x64 means it cano only run in a 64-bit process.

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.

vcsjones
  • 138,677
  • 31
  • 291
  • 286
  • I see. It clears a lot. So, if I want to run my application which uses Microsoft.ACE.OLEDB.12.0 under IIS express, I won't be able to do that on a server that has 64 bit version of office? – trakos Nov 02 '11 at 16:09
  • @trakos You can, you would just have to install the 32-bit components as well which can be downloaded [here](http://www.microsoft.com/download/en/details.aspx?id=13255). You don't have to do a full-blown Office installation just to get these Data Access providers. – vcsjones Nov 02 '11 at 16:14
  • Yes, but the full-blown office installation is also needed on the server, and the Data Access provider for 32bit complains that it won't install because of 64bit office. I believe I have to give up using oledb, rewrite the app to use office interop, and stay with 32bit then? – trakos Nov 02 '11 at 16:19
  • @trakos or use IIS (the one built into the Server's operating system), not IIS Express. That can run 64-bit. – vcsjones Nov 02 '11 at 16:20
  • Yes, but since it runs as a service, it cannot use COM interop, which is also needed (to run procedures in VB.NET code) - I'm stuck between a rock and a hard place. Switching entirely to COM interop seems like the best option, even if it is harder to read the whole workbook. Thank you very much again. – trakos Nov 02 '11 at 16:28