我收到一个 ConfigurationErrorsException“无法找到类 CustomListener 的构造函数”
这与自定义 Systems.Diagnostics.TraceListener 有关。
<system.diagnostics>
<sources>
<source name="SomeTraceSourceName"
switchType="System.Diagnostics.SourceSwitch"
switchName="SomeSwitchName">
<listeners>
<clear />
<add name="CustomListener"/>
</listeners>
</source>
</sources>
<sharedListeners>
<add name="CustomListener"
type="CustomListener, MyAssembly"
initializeData=""/>
</sharedListeners>
<switches>
<add name="SomeSwitchName" value="4" />
</switches>
</system.diagnostics>
默认跟踪侦听器不会发生这种情况。
我发现这个MSDN 帖子,但是最终,它并没有被证明有帮助。
This is related to custom a Systems.Diagnostics.TraceListener
<system.diagnostics>
<sources>
<source name="SomeTraceSourceName"
switchType="System.Diagnostics.SourceSwitch"
switchName="SomeSwitchName">
<listeners>
<clear />
<add name="CustomListener"/>
</listeners>
</source>
</sources>
<sharedListeners>
<add name="CustomListener"
type="CustomListener, MyAssembly"
initializeData=""/>
</sharedListeners>
<switches>
<add name="SomeSwitchName" value="4" />
</switches>
</system.diagnostics>
This doesn't happen with the default trace listener.
I found this MSDN post, but ultimately, it didn't prove helpful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到了——花了很长时间。
关键是这部分:
当 intializationData 是空字符串时,它将寻找不带参数的构造函数。一旦我添加了initializeData的值,框架就找到了构造函数。
错误应该是“没有带有 0 个参数的构造函数,也许您需要包含一些初始化数据”
Found it-- it took a long time.
The key was this part:
When the intializationData is a blank string, it will look for a constructor with no arguments. As soon as I added the value for initializeData then the framework found the constructor.
The error should have said "No constructor with 0 parameters, maybe you need to include some initializeData"