2012-08-27 138 views
0

我使用C#和system.data.sqlite.dll 64內置了WCF服務庫。構建配置是任何CPU。它工作正常。但是,當我改變system.data.sqlite.dll到86位版本,所有CPU配置它成功建立,但是當我運行WCF methords提示錯誤,適用於x86編譯配置它成功地建立,但給下面的錯誤,當我調試它使用wcftestclient。System.Data.Sqlite.dll 32勝和64位C#

System.BadImageFormatException: Could not load file or assembly 'file:///C:\Users\lala\Desktop\New folder\New folder\CoreServiceWCF\CoreServiceWCF\CoreServiceWCF2\bin\x86\Debug\VplusCoreServiceWCF.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format. 
File name: 'file:///C:\Users\lala\Desktop\New folder\New folder\CoreServiceWCF\CoreServiceWCF\CoreServiceWCF2\bin\x86\Debug\VplusCoreServiceWCF.dll' 
    at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) 
    at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) 
    at System.Reflection.Assembly.Load(AssemblyName assemblyRef) 
    at Microsoft.Tools.SvcHost.ServiceHostHelper.LoadServiceAssembly(String svcAssemblyPath) 

=== Pre-bind state information === 
LOG: User = lala-PC\lala 
LOG: Where-ref bind. Location = C:\Users\lala\Desktop\New folder\New folder\CoreServiceWCF\CoreServiceWCF\CoreServiceWCF2\bin\x86\Debug\VplusCoreServiceWCF.dll 
LOG: Appbase = file:///C:/Users/lala/Desktop/New folder/New folder/CoreServiceWCF/CoreServiceWCF/CoreServiceWCF2/bin/x86/Debug 
LOG: Initial PrivatePath = NULL 
Calling assembly : (Unknown). 
=== 
LOG: This bind starts in LoadFrom load context. 
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load(). 
LOG: Using application configuration file: C:\Users\lala\Desktop\New folder\New folder\CoreServiceWCF\CoreServiceWCF\CoreServiceWCF2\bin\x86\Debug\VplusCoreServiceWCF.dll.config 
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config. 
LOG: Attempting download of new URL file:///C:/Users/lala/Desktop/New folder/New folder/CoreServiceWCF/CoreServiceWCF/CoreServiceWCF2/bin/x86/Debug/VplusCoreServiceWCF.dll. 
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated. 

有人幫我解決這個問題嗎?

+0

32和64位可執行文件s不兼容。 32位程序無法加載64位DLL,反之亦然。據我所知,這是一個普遍的限制(即它不能在任何平臺上工作)。 – Wug

+0

你是對的。我的簡單問題是我無法讓我的wcf與system.data.sqlite.dll 32位版本一起工作。 – Proceso

回答

0

當組件被構建爲任何CPU將花費運行的計算機的最佳配置,這意味着,將在64位模式下運行,如果你有一個64位的Windows,它會在32位模式下,如果運行這是在32位的Windows,這個問題似乎是這樣的裝配:VplusCoreServiceWCF.dll,所以我會建議你喲首先檢查該組件的位數,看看它是否是正確的(在你的情況可能是64位)

編輯:挖掘我發現WCF測試客戶端只能運行在64位模式,所以你可能需要強制它到32位,爲此你可以在這裏找到所需的信息:I can't compile a standard "WCF Service Library" in x86 format

+0

VplusCoreServiceWCF.dll這是WCF服務庫項目的生成結果。當我嘗試使用wcftestclient進行調試時,出現上述錯誤。 – Proceso

+0

您需要強制WCF測試客戶端以32位模式運行,請檢查編輯。 – Rafael

+0

yeagh這真的幫助完整,謝謝你的答案拉斐爾:) – Proceso