Microsoft KB Archive/328369

= FIX: PerformanceCounter Class Keeps Remote Registry Handle Open =

Article ID: 328369

Article Last Modified on 10/11/2005

-

APPLIES TO


 * Microsoft .NET Framework 1.0 Service Pack 2

-



This article was previously published under Q328369



SYMPTOMS
When you use the PerformanceCounter class to retrieve performance data from a remote computer, and the remote computer is restarted, you may receive an error message that states that the handle is not valid.



RESOLUTION
A supported hotfix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Only apply it to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next Microsoft .NET Framework service pack that contains this hotfix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the fix. For a complete list of Microsoft Product Support Services phone numbers and information about support costs, visit the following Microsoft Web site:

http://support.microsoft.com/contactus/?ws=support

NOTE: In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The typical support costs will apply to additional support questions and issues that do not qualify for the specific update in question.

The English version of this fix has the file attributes (or later) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.   Date          Version        Size        File name ---  30-Aug-2002   1.0.3705.355   1,171,456   System.dll



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



Steps to Reproduce the Behavior
To reproduce this problem, follow these steps:   Paste the following code in a new file named Test.cs. Replace  with the name of the remote computer that has the performance counters to which you want to gain access. using System; using System.Diagnostics;

class PerfmonProbs{ static void Main {  string machine = &quot;&quot;; long result; Console.WriteLine(&quot;About to connect to &quot; + machine + &quot;.           You need to have ADMIN priviliges on it.&quot;); Console.WriteLine(&quot;Press [ENTER] to continue&quot;); Console.ReadLine; PerformanceCounter counter1 = new PerformanceCounter(&quot;Processor&quot;,          &quot;Interrupts/sec&quot;, &quot;_Total&quot;, machine ); result = (long)counter1.NextValue; Console.WriteLine(&quot;Number of interrupts per second on machine &quot; + machine +           &quot; is &quot; + result); counter1.Close; counter1.Dispose; counter1 = null; Console.WriteLine(&quot;Now reboot the remote server, wait a couple of minutes after it           is back up, and then press [ENTER]&quot;); Console.ReadLine; Console.WriteLine(&quot;About to try to read perf data again.&quot;); Console.WriteLine(&quot;Press [ENTER] to continue&quot;); Console.ReadLine; for (int i = 0;i++<5;){ try { Console.WriteLine(&quot;Attempt &quot; + i.ToString); counter1 = new PerformanceCounter(&quot;Processor&quot;, &quot;Interrupts/sec&quot;,                   &quot;_Total&quot;, machine ); result = (long)counter1.NextValue; Console.WriteLine(&quot;Success:&quot; + result.ToString); }        catch (Exception e)         { Console.WriteLine(e.Message); Console.WriteLine(&quot;at&quot;); Console.WriteLine(e.StackTrace); }

} } }

 Compile the code at a command prompt by using the command CSC TEST.CS. (You must verify that your PATH environment variable gives you access to the C# compiler, Csc.exe.) Run the Test.exe program that you created in step 2, and then follow the onscreen instructions.

The problem occurs after the remote computer has restarted. The exception error is reported when the program tries to gain access to the performance counter on the remote computer.

Keywords: kberrmsg kbbug kbfix kbqfe kbnetframe100presp3fix kbhotfixserver KB328369

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.