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”.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x