我有一個C#WCF服務和一個C#控制檯應用程序,並希望從應用程序傳遞一個大文件到WCF。當我傳遞字符串時,我得到了protocolexception,超出了最大字符串內容長度配額(8192),這是正確的。我將Apps.Config中的ReaderQuotas上的MaxStringContentLength更改爲大量,但沒有任何反應,它仍然是錯誤的。有誰知道爲什麼?我需要添加一些東西到web.config。我的文件內容如下: -ProtocolException被處理,最大字符串內容長度配額8192
的Web.config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
App.Config中
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="88192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="largeStrings" openTimeout="00:02:00" sendTimeout="00:02:00"
maxBufferSize="524288" maxReceivedMessageSize="524288">
<readerQuotas maxDepth="10" maxStringContentLength="524288" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:2745/ActuristDemo/Service.svc"
binding="basicHttpBinding" bindingConfiguration="largeStrings"
contract="ActuristWS.IService" name="largeStrings" />
</client>
</system.serviceModel>
</configuration>
我將這些添加到Web.config項目中,它沒有效果,仍然收到了同樣的問題。我將基地址更改爲app.config中的地址,但仍然是同樣的問題。任何其他建議pleae。 – MiscellaneousUser
解決;-) http://social.msdn.microsoft.com/Forums/eu/wcf/thread/77097d1f-372a-4c7d-910f-57c9ecd9c5c1 – MiscellaneousUser