【问题标题】:CLR Can't find a type, even though it's in the same assemblyCLR 找不到类型,即使它在同一个程序集中
【发布时间】:2012-01-11 19:39:00
【问题描述】:

我正在解决我们应用程序中的 WCF 问题,并在 VS 2010 中使用 WCF 服务配置编辑器打开了 WCF 跟踪,这将以下 sharedListener 添加到 web.config:

    <sharedListeners>
      <add initializeData="D:\Logs\CRCCustomerService\Web_tracelog.svclog"
        type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
        name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
        <filter type="" />
      </add>
    </sharedListeners>

现在,当我采取措施重现我的错误时,我收到 System.Diagostics 库抛出的异常,说它找不到 XmlWriterTraceListener:

Stack Trace: 
System.TypeInitializationException: The type initializer for       'System.ServiceModel.DiagnosticUtility' threw an exception. --->   System.Configuration.ConfigurationErrorsException: Couldn't find type for class System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089. 
at System.Diagnostics.TraceUtils.GetRuntimeObject(String className, Type baseType,    String initializeData) 
at System.Diagnostics.TypedElement.BaseGetRuntimeObject() 
at System.Diagnostics.ListenerElement.GetRuntimeObject() 
at System.Diagnostics.ListenerElement.GetRuntimeObject() 
at System.Diagnostics.ListenerElementsCollection.GetRuntimeObject() 
at System.Diagnostics.TraceSource.Initialize() 
at System.Diagnostics.TraceSource.get_Listeners() 

它又持续了几行,但这建立了上下文。

我的问题是,由于根据 ObjectBrowser 和 Reflector,XmlWriterTraceListener 是 System.Diagnostics 所在程序集的成员类,它怎么可能找不到呢?

其次,由于异常堆栈中的每一行都来自系统代码,我究竟如何开始调试这里的根本原因?

【问题讨论】:

  • 你有没有试过删除所有的程序集信息,只留下这个 type="System.Diagnostics.XmlWriterTraceListener"

标签: system.diagnostics tracelistener


【解决方案1】:

您使用的是 .NET 4.0 吗?

如果没有,您必须小心服务配置实用程序。它将侦听器的版本硬编码为 4.0,您需要手动更改 web.config

【讨论】:

    猜你喜欢
    • 2020-04-04
    • 2011-08-12
    • 2013-03-27
    • 2011-12-11
    • 1970-01-01
    • 2012-10-13
    • 1970-01-01
    • 2017-01-15
    • 1970-01-01
    相关资源
    最近更新 更多