Hi;
I am getting the following:
Unhandled Exception: System.AccessViolationException: Attempted to read or write
protected memory. This is often an indication that other memory is corrupt.
at System.Drawing.SafeNativeMethods.Gdip.GdipMeasureCharacterRanges(HandleRef
graphics, String textString, Int32 length, HandleRef font, GPRECTF& layoutRect,
HandleRef stringFormat, Int32 characterCount, IntPtr[] region)
at System.Drawing.Graphics.MeasureCharacterRanges(String text, Font font, RectangleF layoutRect, StringFormat stringFormat)
at net.windward.env.FormatEngineJava.ParaFormatterDotNet.getBlock(Int32 twips
, Boolean noCharOk) in C:\src\wrDotNet\WindwardReports\net\windward\env\FormatEn
gineJava.jsl:line 337
at net.windward.xmlreport.FinalFormatNodeVisitor.handleText(Boolean adjustTab
) in C:\src\wrDotNet\WindwardReports\net\windward\xmlreport\FinalFormatNodeVisit
or.java:line 1956
at net.windward.xmlreport.FinalFormatNodeVisitor.close() in C:\src\wrDotNet\W
indwardReports\net\windward\xmlreport\FinalFormatNodeVisitor.java:line 3371
at net.windward.xmlreport.FinalFormatNodeVisitor.process(ProcessReport proc,
Document src) in C:\src\wrDotNet\WindwardReports\net\windward\xmlreport\FinalFor
matNodeVisitor.java:line 3400
at net.windward.xmlreport.ProcessReport.processComplete() in C:\src\wrDotNet\
WindwardReports\net\windward\xmlreport\ProcessReport.java:line 1149
at net.windward.xmlreport.ProcessReport.process() in C:\src\wrDotNet\Windward
Reports\net\windward\xmlreport\ProcessReport.java:line 1208
at net.windward.xmlreport.ProcessHtml.process() in C:\src\wrDotNet\WindwardRe
ports\net\windward\xmlreport\ProcessHtml.java:line 199
at net.windward.xmlreport.test.TestThreads.makeReport() in C:\src\wrDotNet\Te
stEngine\net\windward\xmlreport\test\TestThreads.java:line 83
at net.windward.xmlreport.test.TestThreads.ReportThread.run() in C:\src\wrDot
Net\TestEngine\net\windward\xmlreport\test\TestThreads.java:line 203
at System.Threading.ThreadStart.Invoke()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, C
ontextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Any ideas
thanks - dave

Hit a bug
Jaydip_Bagchi
I didn't write a test case but from this it should be easy for you to do so. With 1 thread, no problem. With 2+ threads (my unit test has 16), always get the exception.
I was able to avoid the exception with the following code - by wrapping it in the snychronized. text is usually a single character like "T".
private static final float MAX_RECT = 100000; private System.Drawing.RectangleF getCharRect(String text, System.Drawing.Font font)
{
synchronized (ParaFormatterDotNet.class)
{
System.Drawing.RectangleF rect = new System.Drawing.RectangleF(0, 0, MAX_RECT, MAX_RECT);
System.Drawing.StringFormat fmt = createStringFormat();
fmt.SetMeasurableCharacterRanges(new System.Drawing.CharacterRange[] { new System.Drawing.CharacterRange(0, text.length()) });
System.Drawing.Region[] rgns = graphics.MeasureCharacterRanges(text, font, rect, fmt);
return rgns[0].GetBounds(graphics);
}
}
private System.Drawing.StringFormat createStringFormat()
{
System.Drawing.StringFormat fmt = System.Drawing.StringFormat.get_GenericTypographic();
fmt.set_Trimming(System.Drawing.StringTrimming.None);
fmt.set_FormatFlags(System.Drawing.StringFormatFlags.MeasureTrailingSpaces | System.Drawing.StringFormatFlags.NoWrap);
return fmt;
}
PoulK
It's buried deep in the Windward Reports engine and only occurs in one specific test case.
One thing of note, the test case is when I start 10 threads that all hammer my reporting engine at the same time. So I have several threads all making this call at once. And my system has dual processors so 2 threads are actually running at the same time.
My code is 100% managed code so theoriticly this exception should be impossible.
thanks - dave
wjvii1437
If you can provide us a brief repro that isolates this problem, we should be able to debug it for you.
Since this problem seems to be more specific to .NET, you can also try posting the access violation on the .NET forum (http://ddweb/answerme/questions.aspx forumID=39).
regards
Prem
VJ# team< xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
g_hall
KevinC
http://winfx.msdn.microsoft.com/library/default.asp url=/library/en-us/dv_vsdebug/html/7f09315d-8aad-4ab1-8b5e-21a8c97f6c14.asp
thanks
Prem
VJ# Team