Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2010: how to force ASP.NET website to use x86 instead of "Any CPU"?

When using SharePoint DLLs (which are x86 only) from a non-ASP.NET app, you can set the "Platform target" to x86 (instead of "Any CPU") so both Visual Studio 2010 and the app load the SharePoint assemblies fine.

However, when developing ASP.NET applications on an x64 development system, you get this dreaded error message when building the web-site:

Could not load file or assembly 'Microsoft.SharePoint.Search' or one of its dependencies. An attempt was made to load a program with an incorrect format.

This is because ASP.NET by default is "Any CPU" when building in Visual Studio 2010.

How can I change that?

I tried the property pages for the web-site, the web.config, but to no avail.

Note: this is for the development system. I know that for the server system, I can change the application pool to force loading of 32-bit x86 by setting "Enable 32-Bit Applications" to "True" in the "Application Pool Defaults".

like image 427
Jeroen Wiert Pluimers Avatar asked Apr 13 '11 22:04

Jeroen Wiert Pluimers


1 Answers

You can set custom compiler option on web.config on the <compilers>

compilerOptions="/platform:string"

where string can be found here: http://msdn.microsoft.com/en-us/library/zekwfyz4(VS.80).aspx

like image 141
Aristos Avatar answered Sep 24 '22 13:09

Aristos