Microsoft KB Archive/326281

= BUG: ArgumentOutOfRangeException Error Occurs in PerfMon Sample =

Article ID: 326281

Article Last Modified on 1/19/2004

-

APPLIES TO


 * Microsoft Visual J# .NET 2003 Standard Edition

-



This article was previously published under Q326281



SYMPTOMS
When you click the context menus on the graphic display panels of the multiple-document interface (MDI) child windows in the PerfMon sample, the menus do not work.

When you run the PerfMon sample in the debugger, an unhandled exception error occurs, and you receive the following error message:

An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll

Additional information: Length cannot be less than zero.

When you run the PerfMon sample outside the debugger, an unhandled exception error occurs, and you receive the following error message:

An unhandled exception has occurred in your application. If you click Continue, the application will ignore this error and attempt to continue. If you click Quit, the application will be shut down immediately.

Length cannot be less than zero.

Parameter name: length.



CAUSE
A bug exists in the event handler code for these context menus.



RESOLUTION
To resolve this problem, edit the sample code so that the string argument that causes the error contains no space characters.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



MORE INFORMATION
Another bug in the sample distribution for Visual J# .NET causes a missing file error. The sample does not compile or run without the DisplayForm.jsl file. For additional information about how to obtain the missing file, click the article number below to view the article in the Microsoft Knowledge Base:

325599 BUG: 'VJS1005 - File Not Found' Error Message with PerfMon Sample

Steps to Reproduce the Behavior
 In the Visual J# .NET Help collection, open the PerfMon sample. To do this, click Visual J#, click Visual J# Samples, click General Samples, and then click PerfMon Sample. At the bottom of the Sample Files pane on the upper right of the page, click the Copy All Files link to copy the sample files to your hard disk. Open the sample project in Visual J# .NET, and then run the project in Debug mode. In one of the MDI child windows, click Load Counters. When the status bar indicates that the counters are loaded, locate and expand IP.</li> Click to select Fragments Created/sec.</li> On the IP tab that is created on the display panel to the right of the counter list, right-click the graphing component for the Fragments Created/sec counter, and then click Fragments Created/sec.</li> When you receive the error message, you can break in the Visual J# .NET debugger on the problem line. Click Break.</li>  The Visual J# debugger breaks on line 428 in the DisplayPanel.jsl file. Remove the spaces from the string argument to the IndexOf(String) method to fix the problem: Edit the sample code and change the following line System.String CounterName = mi.get_Text .Substring ( 0,mi.get_Text .IndexOf ( &quot; * &quot; ) - 1 ).Trim ; to: System.String CounterName = mi.get_Text .Substring ( 0,mi.get_Text .IndexOf ( &quot;*&quot; ) - 1 ).Trim ; </li> Re-compile the sample, and then run the sample again. Note that the context menus now work correctly.</li></ol>

<div class="references_section">