BUG: ArgumentOutOfRangeException Error Occurs in PerfMon Sample (326281)



The information in this article applies to:

  • Microsoft Visual J# .NET (2002)

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

  1. 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.
  2. 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.
  3. Open the sample project in Visual J# .NET, and then run the project in Debug mode.
  4. In one of the MDI child windows, click Load Counters.
  5. When the status bar indicates that the counters are loaded, locate and expand IP.
  6. Click to select Fragments Created/sec.
  7. 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.
  8. When you receive the error message, you can break in the Visual J# .NET debugger on the problem line. Click Break.
  9. 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 ( " * " ) - 1 ).Trim ();
    					
    to:
    System.String CounterName = mi.get_Text ().Substring ( 0,mi.get_Text ().IndexOf ( "*" ) - 1 ).Trim ();
    					
  10. Re-compile the sample, and then run the sample again. Note that the context menus now work correctly.

REFERENCES

For more information about Java language support on .NET, visit the following Microsoft Developer Network (MSDN) Web site:

Modification Type:MajorLast Reviewed:1/19/2004
Keywords:kbbug kbpending KB326281