1

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

例外是:

'System.ServiceModel.Diagnostics.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>

我该如何解决这个问题?

4

3 回答 3

1

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

<commonBehaviors>
    <serviceBehaviors>
        <serviceTimeouts transactionTimeout="01:55:00"/>
    </serviceBehaviors>
</commonBehaviors>
于 2013-07-23T08:32:06.163 回答
0

这件事刚刚发生在我身上。我想到了分享,尽管它很傻。

这是我所做的

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

我在配置中添加了一个键值对值,但它没有位于配置的 appSettings 部分中。在我匆忙测试服务时,我运行了我的控制台应用程序并得到了完全相同的错误。

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

一旦我在 appSettings 部分中添加了键值对,它就起作用了。我知道这很愚蠢,但它仍然发生在我身上。:)。

于 2014-06-16T08:45:09.480 回答
0

我有类似的异常,问题是

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

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

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

于 2016-03-04T15:50:28.013 回答