4

I have a method like this:

var stringReader = new StringReader(ruleSetXmlDefinition);
var reader = XmlReader.Create(stringReader);
var serializer = new WorkflowMarkupSerializer();
return serializer.Deserialize(reader) as RuleSet;

When the ruleSetXmlDefinition is greater than 32768 characters long I get the following error:

Unexpected end of file while parsing Name has occurred. Line 1, position 32768.

How can I change this so that it can handle strings of any length?

Justin
  • 84,773
  • 49
  • 224
  • 367
David Ward
  • 3,739
  • 10
  • 44
  • 66

2 Answers2

3

I suspect you can configure Wcf to accept bigger arrays, see also this answer:

Something like

<netTcpBinding>
        <binding name="NetTcpBinding_ImageResizerServiceContract" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="10"
maxReceivedMessageSize="2147483647">
                <readerQuotas maxDepth="2147483647"
                                          maxStringContentLength="2147483647"
                                          maxArrayLength="2147483647"
                                          maxBytesPerRead="2147483647"
                                          maxNameTableCharCount="2147483647" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
                <security mode="Transport">
                        <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                        <message clientCredentialType="Windows" />
                </security>
        </binding>

</netTcpBinding>
Community
  • 1
  • 1
sehe
  • 374,641
  • 47
  • 450
  • 633
  • This method is not being exposed over WCF, it is just a simple local method – David Ward Nov 18 '11 at 14:19
  • @DavidWard: I noticed you didn't say so, yet WorkflowMarkupSerializer is part of WCF so the configuration might apply. You can search MSDN for a way to globally override the defaults – sehe Nov 18 '11 at 14:21
  • Thanks for this but I am unable to find any further information about setting WCF config globally. Also, this code works fine when below the character limit and I don't have any WCF config anywhere in the application so don't see how this could help – David Ward Nov 18 '11 at 14:33
  • @DavidWard: huh, that would be because of default values? Well, sorry I can't help you any further a.t.m. – sehe Nov 18 '11 at 14:42
1

I have found the answer to this issue and unfortunately it was something really obvious...the string I was passing in was actually being truncated so the issue was actually that the xml was not well formed.

David Ward
  • 3,739
  • 10
  • 44
  • 66