0

我有一个使用 c# 和 system.data.sqlite.dll x64 构建的 WCF 服务库。构建配置是任何 CPU。它工作正常。但是,当我将 system.data.sqlite.dll 更改为 x86 位版本时,对于任何 CPU 配置,它都会成功构建,但是当我运行 wcf 方法时,它会给出错误,对于 x86 构建配置,它会成功构建,但在调试时会出现以下错误使用 wcftestclient。

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.

有人帮我解决这个问题吗?

4

1 回答 1

0

当为任何 CPU 构建程序集时,它将采用您运行的计算机的最佳配置,这意味着如果您有 64 位 Windows,它将以 64 位模式运行,如果它在 32 位,它将以 32 位模式运行位 Windows,问题似乎是这个程序集:VplusCoreServiceWCF.dll,所以我建议你先检查这个程序集的位数,看看它是否正确(在你的情况下可能是 64 位)

编辑:四处挖掘我发现 WCF 测试客户端仅在 64 位模式下运行,因此您可能需要将其强制为 32 位,为此您可以在此处找到所需的信息:我无法编译标准的“WCF 服务库” " x86 格式

于 2012-08-27T17:27:17.543 回答