2013-07-23 175 views
1

我開發了一個使用C#的控制檯應用程序來訪問另一個API並提取相關數據。當我檢查了少量的數據輸入時,它工作正常。當我使用大量數據進行負載測試時,它會引發異常。'System.ServiceModel.Diagnostics.TraceUtility'的類型初始值設定項引發異常

例外情況是:

關於 '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> 

我該如何解決這個問題?

+0

發佈的XML格式不正確 - 帶有的行。你的意思是「」(一個空的XML標籤)?還是缺少某些東西? –

回答

1

該問題已被克服。可能我有兩個app.config文件。一個來自服務參考,另一個來自我的應用程序。兩者都有相同的代碼。我只是從我的應用程序中放置的appl.config中刪除了下面的代碼。現在它不會拋出上述例外。

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

剛剛發生在我身上。我想到分享,即使它很愚蠢。

這裏是我做過什麼

我在一個控制檯應用程序添加引用WCF服務。

我在配置文件中添加了一個鍵值對值,但它並不在appSettings部分中。在我急於測試服務時,我運行了我的控制檯應用程序,並得到了完全相同的錯誤。

在進入錯誤細節時,我想這是因爲我的配置中的無效配置項。

一旦我在appSettings部分添加了鍵值對,它就起作用了。我知道這很愚蠢,但它仍然發生在我身上。 :)。

0

我有類似的例外,問題是有兩個配置文件

1),並在網絡層/ app.config的服務也有類似的設置(web.config層,我們調用外部服務)

2)無效部分在web.config(log4net配置部分)

Visual Studio沒有顯示任何#2的錯誤,因爲它的VS看起來有效的部分,但在運行時它拋出錯誤。刪除服務層中的app.config並解決問題。

相關問題