Question : StringBuilder overflowed by unmanaged code

I'm using .NET Framework 1.0.3705 to build an automation tool that processes a lot of files, and keeps logs on what it's doing.  At some point in a larger run (I don't have access to the user's full data set), a user received the following error message:

"Warning: A StringBuilder buffer has been overflowed by unmanaged code.  The process may become unstable.  Insufficient capacity allocated to the StringBuilder before marshaling it."

The question is: what might cause this?  I'm not actually using StringBuilder directly (though I can see that maybe I should); I am concatenating some potentially large strings for logging and reporting.

Unfortunately, I don't know where in my code this is happening, only that it isn't happening on my smaller data set.  In different places, I call TextBox.appendLine, textbox.text (set), StreamWriter.WriteLine, and StreamWriter.Write.  Those are the only calls that I can think of that might use StringBuilder.  (Does inline concatenation of strings use StringBuilder?  I do that, too, of course: a = b & c.)

Extrapolating from my smaller data set, I'd estimate that the largest these strings could get is around 600,000 characters long.  By default, StringBuilder has a maximum capacity of Int32.MaxValue (2,147,483,647) characters, according to this:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemTextStringBuilderClassTopic.asp

So that's curious.  I'm also curious about the error's claim that this is happening in unmanaged code.  I thought that .NET was all managed code.

The user is presently running the job again (it takes a few hours) to regenerate output that he deleted.  I might know more after he finishes that; if so, I will post here again.

Thanks in advance!

Answer : StringBuilder overflowed by unmanaged code

What happens without the Application.DoEvents?  What is it's intended purpose?  Is it intended to increase system responsiveness?

Bob
Random Solutions  
 
programming4us programming4us