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

When using a SharePoint DLL (x86 only) from a nonASP.NET application, you can set the “target platform” to x86 (instead of “Any CPU”), therefore both Visual Studio 2010 and the application load SharePoint assemblies perfectly.

However, when developing ASP.NET applications on an x64 development system, you get this dangerous error message when creating a website:

Failed to load file or assembly "Microsoft.SharePoint.Search" or one of its dependencies. The attempt was to download the program using the wrong format.

This is because ASP.NET is by default “Any CPU” when created in Visual Studio 2010.

How to change this?

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

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

+8
visual-studio-2010 sharepoint-2010
source share
1 answer

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

 compilerOptions="/platform:string" 

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

+7
source share

All Articles