如果我启动Microsoft Visual Studio,创建一个标准的"WCF服务库",并编译它,它完美地工作.
但是,如果我进入Properties..Build并将"Platform Target"设置为"x86",它将无法编译.我需要"x86",因为我需要引用一些.dll,如果选择"所有平台",它将无法工作.
-----start error-----
System.BadImageFormatException: Could not load file or assembly 'file:///D:\backtest\C#\WCF service\WcfServiceLibrary\bin\Debug\WcfServiceLibrary.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.
File name: 'file:///D:\backtest\C#\WCF service for\WcfServiceLibrary\bin\Debug\WcfServiceLibrary.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 = dr-satellite\Shane
LOG: Where-ref bind. Location = D:\backtest\C#\WCF service for\WcfServiceLibrary\bin\Debug\WcfServiceLibrary.dll
LOG: Appbase = file:///D:/backtest/C#/WCF service for/WcfServiceLibrary/bin/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: D:\backtest\C#\WCF service for\WcfServiceLibrary\bin\Debug\WcfServiceLibrary.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:///D:/backtest/C#/WCF service for/WcfServiceLibrary/bin/Debug/WcfServiceLibrary.dll.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.
-----end error-----
Run Code Online (Sandbox Code Playgroud)
Str*_*tch 13
您的问题实际上是WCF测试客户端抱怨您的WCF服务库是32位.这是因为默认情况下,WCF测试客户端始终以64位模式运行.
我没有花时间更改为WCF服务应用程序以便进行调试,而是在此博客上找到了以下步骤,使WCF测试客户端以32位模式运行 - 因此您不会看到已发布的错误.
"cd"到您的WcfSvcHost副本所在的目录.
执行命令"corflags/32BIT +/FORCE WcfSvcHost.exe"
执行命令"corflags/32BIT +/FORCE WcfTestClient"
将文件复制回您找到的位置.
现在您的WcfSvcHost和WcfTestClient将以32位模式运行,您可以调试!
我找到了两种解决这个问题的好方法:
归档时间: |
|
查看次数: |
9304 次 |
最近记录: |