2016-01-29 50 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