Visual Studio 2010:如何强制ASP.NET网站使用x86而不是“Any CPU”?

时间:2023-01-06 07:35:57

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.

从非ASP.NET应用程序使用SharePoint DLL(仅限x86)时,可以将“平台目标”设置为x86(而不是“任何CPU”),以便Visual Studio 2010和应用程序加载SharePoint程序集。

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

但是,在x64开发系统上开发ASP.NET应用程序时,在构建Web站点时会收到这个可怕的错误消息:

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.

无法加载文件或程序集“Microsoft.SharePoint.Search”或其依赖项之一。尝试加载格式不正确的程序。

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

这是因为在Visual Studio 2010中构建时,默认情况下ASP.NET是“任何CPU”。

How can I change that?

我怎么能改变呢?

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

我尝试了网站的属性页面,即web.config,但无济于事。

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

注意:这是针对开发系统的。我知道对于服务器系统,我可以通过在“应用程序池默认值”中将“启用32位应用程序”设置为“True”来更改应用程序池以强制加载32位x86。

1 个解决方案

#1


7  

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

您可以在 上的web.config上设置自定义编译器选项

compilerOptions="/platform:string"

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

其中字符串可以在这里找到:http://msdn.microsoft.com/en-us/library/zekwfyz4(VS.80).aspx

#1


7  

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

您可以在 上的web.config上设置自定义编译器选项

compilerOptions="/platform:string"

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

其中字符串可以在这里找到:http://msdn.microsoft.com/en-us/library/zekwfyz4(VS.80).aspx