包含 NServiceBus 和 WCF 的配置文件失败
我无法弄清楚下面的配置代码有什么问题,当我包含 NServiceBus 配置信息时,出现以下错误:
“System.ServiceModel.Diagnostics.TraceUtility”的类型初始值设定项引发了异常“
当我注释掉时,该消息消失了NServiceBus 代码,因此它与 .net 框架的错误安装无关,就像一些互联网建议的那样。
任何想法将不胜感激!
当我的代码到达以下几点的 WebClient 构造函数
WEBCallback = new CFPWebImplementation();
WEBContext = new InstanceContext(WEBCallback);
WEBClient = new TradeOperationsClient(WEBContext);
和我的配置文件时,会导致错误:
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_ITradeOperations" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="None">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:8687/TradePortal/Operations/"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_ITradeOperations"
contract="CFP_Web.ITradeOperations" name="NetTcpBinding_ITradeOperations" />
</client>
</system.serviceModel>
<configSections>
<section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core"/>
<section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core"/>
</configSections>
<MsmqTransportConfig InputQueue="HammersmithInputQueue" ErrorQueue="error" NumberOfWorkerThreads="1" MaxRetries="5"/>
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="Messages" Endpoint="BBRGInputQueue"/>
</MessageEndpointMappings>
</UnicastBusConfig>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
I cant figure out whats wrong with my config code below, when I include the NServiceBus config info I get the followng error:
The Type Initializer for 'System.ServiceModel.Diagnostics.TraceUtility' threw an exception'
The message goes away when I comment out the NServiceBus code so its not related to a faulted instal of the .net framework like some of the interwebs suggested.
Any ideas would be appreciated!
The error is caused when my code gets to the constructor for WebClient belowfollowing point:
WEBCallback = new CFPWebImplementation();
WEBContext = new InstanceContext(WEBCallback);
WEBClient = new TradeOperationsClient(WEBContext);
and my config file:
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_ITradeOperations" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="None">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:8687/TradePortal/Operations/"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_ITradeOperations"
contract="CFP_Web.ITradeOperations" name="NetTcpBinding_ITradeOperations" />
</client>
</system.serviceModel>
<configSections>
<section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core"/>
<section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core"/>
</configSections>
<MsmqTransportConfig InputQueue="HammersmithInputQueue" ErrorQueue="error" NumberOfWorkerThreads="1" MaxRetries="5"/>
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="Messages" Endpoint="BBRGInputQueue"/>
</MessageEndpointMappings>
</UnicastBusConfig>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
结果答案是,需要成为 app.config 文件中的第一个元素
Turns out the answer was that the needs to be the first element in the app.config file