我有一个WCF服务,它有许多方法,包括一个如下所示:
private void TraceEvent(object sender, TraceEventArgs eventArgs)
{
try
{
this._ApiEvents.TraceEvent(eventArgs);
}
catch (System.ServiceModel.CommunicationObjectAbortedException)
{
// The Client has disconnected. Absorb this exception so that we can finish gracefully.
}
}
eventArgs有两个属性,一个整数和一个字符串。现在,如果字符串很短,这没有问题。但是如果字符串很长,例如我有一个大约30,000字节长,然后这不起作用。我试过以编程方式更改绑定的值:
XmlDictionaryReaderQuotas myReaderQuotas = new XmlDictionaryReaderQuotas();
myReaderQuotas.MaxStringContentLength = 2;
myReaderQuotas.MaxArrayLength = 2;
myReaderQuotas.MaxBytesPerRead = 2;
myReaderQuotas.MaxDepth = 2;
myReaderQuotas.MaxNameTableCharCount = 2;
binding.GetType().GetProperty("ReaderQuotas").SetValue(binding, myReaderQuotas, null);
binding.MaxBufferPoolSize = 2;
binding.MaxBufferSize = 2;
binding.MaxReceivedMessageSize = 2;
将所有内容设置为2以便打破它以确保我设置正确的值。但它一切正常,所以似乎这些价值被忽略了。知道这里可能会发生什么吗?