【问题标题】:WCF Service Project Runs In Debug, but Crashes in ReleaseWCF 服务项目在调试中运行,但在发布时崩溃
【发布时间】:2016-08-29 20:49:26
【问题描述】:

我正在尝试在发布模式下运行我的项目,但遇到了一个问题:我立即崩溃,出现以下异常:

An unhandled exception of type 'System.ServiceModel.ProtocolException' occurred in 
mscorlib.dll

Additional information: The content type text/html; charset=utf-8 of the response message 
does not match the content type of the binding (text/xml; charset=utf-8). If using a 
custom encoder, be sure that the IsContentTypeSupported method is implemented properly. 
The first 1024 bytes of the response were: 
    '<!DOCTYPE html>
     <html>
      <head>
       <title>Could not load file or assembly 'MyNamespace.MySolution.MyProject' 
        or one of its dependencies. An attempt was made to load a program with an 
        incorrect format.
       </title>

内部异常是(500) Internal Server Error.

我尝试在调试器中启动发布版本并在该错误发生之前单步执行代码,但我无法进一步执行代码 - 它不提供附加到服务器进程,只是抛出错误。我见过几个类似的问题,但似乎没有解决这个问题。如有任何建议,我将不胜感激。

【问题讨论】:

  • 我不认为你可以调试发布版本代码(但我不是 100% 确定)。错误消息似乎很清楚 - “无法加载文件或程序集'MyNamespace.MySolution.MyProject'或其依赖项之一。尝试加载格式不正确的程序。”
  • 您是否更改了运行时?可能您正在使用Debug 配置,即x86,而您的Release 配置是x64。我敢打赌,或者你的依赖项之一就是这样设置的。
  • 这可能不是真的,但以防万一:响应是html,但绑定是xml

标签: c# .net visual-studio wcf release


【解决方案1】:

正如 Tim 正确指出的那样,服务可能由于缺少程序集而引发错误。

最可能的原因可能是“发布”配置中缺少服务项目中引用的程序集之一。

【讨论】:

    猜你喜欢
    • 2018-09-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多