我无法编译标准的“WCF 服务库";x86 格式 [英] I can't compile a standard "WCF Service Library" in x86 format

查看:20
本文介绍了我无法编译标准的“WCF 服务库";x86 格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我启动 Microsoft Visual Studio,创建一个标准的WCF 服务库"并编译它,它会完美运行.

If I start up Microsoft Visual Studio, create a standard "WCF Service Library", and compile it, it works perfectly.

但是,如果我进入 Properties..Build 并将平台目标"设置为x86",它将无法编译.我需要x86",因为我需要引用一些 .dll,如果我选择所有平台",这些 .dll 将无法正常工作.

However, if I go into Properties..Build and set the "Platform Target" to "x86", it won't compile. I need "x86" because I need to reference some .dll's that simply won't work if I choose "All Platforms".

-----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-----

推荐答案

我找到了两个很好的方法来解决这个问题:

I found two good methods to solve this:

  1. 安装 64 位版本的 Matlab 意味着您可以编译与 64 位 WCF 服务库兼容的 64 位 .dll.这消除了在 32 位模式下编译的需要,因此它在调用 32 位程序集时不会抛出异常.此解决方案运行良好.
  2. 您可以在 MSVS 2010 中生成两种类型的项目:WCF 服务库"和WCF 服务应用程序".尽管您不能在 32 位模式下构建和运行WCF 服务库"(它仅支持 64 位),但您可以在 32 位模式下构建和运行WCF 服务应用程序".
  1. Installing the 64-bit version of Matlab means you can compile 64-bit .dll's which are compatible with the 64-bit WCF Service Library. This removes the need to compile in 32-bit mode so it doesn't throw exceptions when it calls the 32-bit assembly. This solution works well.
  2. There are two types of projects you can generate in MSVS 2010: "WCF Service Library" and "WCF Service Application". Although you cannot build and run a "WCF Service Library" in 32-bit mode (it only supports 64-bit), you can build and run a "WCF Service Application" in 32-bit mode.

这篇关于我无法编译标准的“WCF 服务库";x86 格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆