"System.ServiceModel.Diagnostics.TraceUtility"的类型初始值设定项引发异常



我使用C#开发了一个控制台应用程序,以访问另一个API并提取相关数据。当我用少量数据输入进行检查时,它工作得很好。当我用大量数据进行负载测试时,它抛出了一个异常。

例外情况是:

"System.ServiceModel.Diagnostic.TraceUtility"的类型初始值设定项引发异常。

我的app.config:

<?xml version="1.0"?>
<configuration>
    <commonBehaviors>
        <serviceBehaviors>
            <serviceTimeouts transactionTimeout="01:55:00"/>
        </serviceBehaviors>
    </commonBehaviors>
    <bindings>
        <customBinding>
            <binding name="EloquaService"
                     closeTimeout="00:55:00"
                     openTimeout="00:55:00"
                     receiveTimeout="00:55:00"
                     sendTimeout="01:55:00">
                <security defaultAlgorithmSuite="Default"
                          authenticationMode="UserNameOverTransport"
                          requireDerivedKeys="true"
                          securityHeaderLayout="Strict"
                          includeTimestamp="true"
                          keyEntropyMode="CombinedEntropy"
                          messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
                    <localClientSettings cacheCookies="true"
                                         detectReplays="false"
                                         replayCacheSize="900000"
                                         maxClockSkew="00:05:00"
                                         maxCookieCachingTime="Infinite"
                                         replayWindow="00:05:00"
                                         sessionKeyRenewalInterval="10:00:00"
                                         sessionKeyRolloverInterval="00:05:00"
                                         reconnectTransportOnFailure="true"
                                         timestampValidityDuration="00:05:00"
                                         cookieRenewalThresholdPercentage="60"/>
                    <localServiceSettings detectReplays="false"
                                          issuedCookieLifetime="10:00:00"
                                          maxStatefulNegotiations="128"
                                          replayCacheSize="900000"
                                          maxClockSkew="00:05:00"
                                          negotiationTimeout="00:01:00"
                                          replayWindow="00:05:00"
                                          inactivityTimeout="00:02:00"
                                          sessionKeyRenewalInterval="15:00:00"
                                          sessionKeyRolloverInterval="00:05:00"
                                          reconnectTransportOnFailure="true"
                                          maxPendingSessions="128"
                                          maxCachedCookies="1000"
                                          timestampValidityDuration="00:05:00"/>
                    <secureConversationBootstrap/>
                </security>
                <textMessageEncoding maxReadPoolSize="64"
                                     maxWritePoolSize="16"
                                     messageVersion="Soap11"
                                     writeEncoding="utf-8">
                    <readerQuotas maxDepth="32"
                                  maxStringContentLength="8192"
                                  maxArrayLength="16384"
                                  maxBytesPerRead="4096"
                                  maxNameTableCharCount="16384"/>
                </textMessageEncoding>
                <httpsTransport manualAddressing="false"
                                maxBufferPoolSize="524288"
                                maxReceivedMessageSize="65536"
                                allowCookies="false"
                                authenticationScheme="Anonymous"
                                bypassProxyOnLocal="false"
                                decompressionEnabled="true"
                                hostNameComparisonMode="StrongWildcard"
                                keepAliveEnabled="true"
                                maxBufferSize="65536"
                                proxyAuthenticationScheme="Anonymous"
                                realm=""
                                transferMode="Buffered"
                                unsafeConnectionNtlmAuthentication="false"
                                useDefaultWebProxy="true"
                                requireClientCertificate="false"/>
            </binding>
            <binding name="EmailServiceEndpoint"
                     closeTimeout="00:55:00"
                     openTimeout="00:55:00"
                     receiveTimeout="00:55:00"
                     sendTimeout="01:55:00">
                <security defaultAlgorithmSuite="Default"
                          authenticationMode="UserNameOverTransport"
                          requireDerivedKeys="true"
                          securityHeaderLayout="Strict"
                          includeTimestamp="true"
                          keyEntropyMode="CombinedEntropy"
                          messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
                    <localClientSettings cacheCookies="true"
                                         detectReplays="false"
                                         replayCacheSize="900000"
                                         maxClockSkew="00:05:00"
                                         maxCookieCachingTime="Infinite"
                                         replayWindow="00:05:00"
                                         sessionKeyRenewalInterval="10:00:00"
                                         sessionKeyRolloverInterval="00:05:00"
                                         reconnectTransportOnFailure="true"
                                         timestampValidityDuration="00:05:00"
                                         cookieRenewalThresholdPercentage="60"/>
                    <localServiceSettings detectReplays="false"
                                          issuedCookieLifetime="10:00:00"
                                          maxStatefulNegotiations="128"
                                          replayCacheSize="900000"
                                          maxClockSkew="00:05:00"
                                          negotiationTimeout="00:01:00"
                                          replayWindow="00:05:00"
                                          inactivityTimeout="00:02:00"
                                          sessionKeyRenewalInterval="15:00:00"
                                          sessionKeyRolloverInterval="00:05:00"
                                          reconnectTransportOnFailure="true"
                                          maxPendingSessions="128"
                                          maxCachedCookies="1000"
                                          timestampValidityDuration="00:05:00"/>
                    <secureConversationBootstrap/>
                </security>
                <textMessageEncoding maxReadPoolSize="64"
                                     maxWritePoolSize="16"
                                     messageVersion="Soap11"
                                     writeEncoding="utf-8">
                    <readerQuotas maxDepth="32"
                                  maxStringContentLength="8192"
                                  maxArrayLength="16384"
                                  maxBytesPerRead="4096"
                                  maxNameTableCharCount="16384"/>
                </textMessageEncoding>
                <httpsTransport manualAddressing="false"
                                maxBufferPoolSize="524288"
                                maxReceivedMessageSize="65536"
                                allowCookies="false"
                                authenticationScheme="Anonymous"
                                bypassProxyOnLocal="false"
                                decompressionEnabled="true"
                                hostNameComparisonMode="StrongWildcard"
                                keepAliveEnabled="true"
                                maxBufferSize="65536"
                                proxyAuthenticationScheme="Anonymous"
                                realm=""
                                transferMode="Buffered"
                                unsafeConnectionNtlmAuthentication="false"
                                useDefaultWebProxy="true"
                                requireClientCertificate="false"/>
            </binding>
        </customBinding>
    </bindings>
    <client>
        <endpoint address="https://secure.eloqua.com/API/1.2/service.svc"
                  binding="customBinding"
                  bindingConfiguration="EloquaService"
                  contract="EloquaService.EloquaService"
                  name="EloquaService"/>
        <endpoint address="https://secure.eloqua.com/API/1.2/ExternalActionService.svc"
                  binding="customBinding"
                  bindingConfiguration="EmailServiceEndpoint"
                  contract="EloquaProgramService.ExternalActionService"
                  name="EmailServiceEndpoint"/>
    </client>
    </system.serviceModel>
    <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
    </startup>
</configuration>

我该如何解决这个问题?

问题已经解决。可能我有两个app.config文件。一个来自服务参考,另一个来自我的应用程序。两者的代码相同。我刚刚从应用程序中的app.config中删除了以下代码。现在它没有抛出上述异常。

<commonBehaviors>
    <serviceBehaviors>
        <serviceTimeouts transactionTimeout="01:55:00"/>
    </serviceBehaviors>
</commonBehaviors>

这件事刚才发生在我身上。我想过分享,尽管这很傻。

以下是我做的

我在控制台应用程序中添加了对WCF服务的引用。

我在配置中添加了一个键值对值,但它不在配置的appSettings部分中。在匆忙测试服务的过程中,我运行了控制台应用程序,却出现了完全相同的错误。

在查看错误详细信息时,我认为这是因为我的配置中有无效的配置条目。

一旦我在appSettings部分中添加了键值对,它就起作用了。我知道这很傻,但它还是发生在我身上。

我遇到了类似的异常,问题是

1) 有两个配置文件,并且有类似的设置(Web层中的web.config/服务层中的app.config,我们调用外部服务)

2) web.config(log4net配置部分)中的无效部分

Visual studio没有显示no#2的任何错误,因为它看起来对VS有效,但在运行时它抛出了错误。删除了服务层中的app.config,解决了问题。

相关内容

  • 没有找到相关文章

最新更新