2016-01-29 61 views
1

我在VS2015中运行Asp.Net Razor应用程序。当我在64位调试模式下运行,我得到以下错误:VS2015项目在x64平台下崩溃

[BadImageFormatException: Could not load file or assembly 'MyWebApp.DAL' 
or one of its dependencies. An attempt was made 
to load a program with an incorrect format.] 

Assembly Load Trace: The following information can be helpful to determine why the assembly 'MyApp.DAL' could not be loaded. 
 

 

 
=== Pre-bind state information === 
 
LOG: DisplayName = MyApp.DAL 
 
(Partial) 
 
WRN: Partial binding information was supplied for an assembly: 
 
WRN: Assembly Name: MyApp.DAL | Domain ID: 2 
 
WRN: A partial bind occurs when only part of the assembly display name is provided. 
 
WRN: This might result in the binder loading an incorrect assembly. 
 
WRN: It is recommended to provide a fully specified textual identity for the assembly, 
 
WRN: that consists of the simple name, version, culture, and public key token. 
 
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue. 
 
LOG: Appbase = file:///C:/MyApp/MyApp.WebApp/ 
 
LOG: Initial PrivatePath = C:\MyApp\WebApp\bin 
 
Calling assembly : (Unknown). 
 
=== 
 
LOG: This bind starts in default load context. 
 
LOG: Using application configuration file: C:\...\web.config 
 
LOG: Using host configuration file: C:\Users\...\Documents\IISExpress\config\aspnet.config 
 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. 
 
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind). 
 
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/76dd151c/b29594f/MyApp.DAL.DLL. 
 
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/76dd151c/b29594f/MyApp.DAL/MyApp.DAL.DLL. 
 
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.

如果我修改生成根据企业的性质(调试 - >属性menut项目)“活动(调试)“平台设置为”活动(x86)“ - 所有运行良好。

我确实有.Net Framework 4.6.1,产品版本4.6.01055。 而按照注册表编辑器:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client\1033] 
"Version"="4.6.01055" 
"TargetVersion"="4.0.0" 
"Install"=dword:00000001 
"Servicing"=dword:00000000 
"Release"=dword:0006041f 

帮助表示赞赏,所以我能得到这个在x64平台上运行。

鲍勃

+0

我已将平台(x86)添加到我的解决方案的配置管理器(Buid - > Cgf Mngr),并在x86下运行。我的项目现在运行。为什么它不能在任何Cpu下运行,或者在x64下运行 - 我仍然不明白。 –

+1

查看项目属性

+0

@ChrisMarisic - 我简直不敢相信答案是那么简单。是的,它适用于“任何CPU”。请添加为您的答案。 –

回答

1

看项目属性<生成的MyApp.DAL项目。该项目的平台目标的构建设置应该是任何CPU