Results 1 to 3 of 3

Thread: [RESOLVED] I have a problem with PerformanceCounter

  1. #1

    Thread Starter
    PowerPoster Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Bottesford, North Lincolnshire, England.
    Posts
    2,423

    Resolved [RESOLVED] I have a problem with PerformanceCounter

    Hi,

    I have a project which currently consists of Form1, Button1, Label1 and Timer1.
    vb.net Code:
    1. Imports Microsoft.Win32
    2. Imports System.IO
    3.  
    4. Public Class Form1
    5.  
    6.     Private Sub Form1_Load() Handles MyBase.Load
    7.      
    8.     End Sub
    9.  
    10.     Private Sub Button1_Click() Handles Button1.Click
    11.         Me.Close()
    12.     End Sub
    I can run this code with no problem.

    I want to add a PerformanceCounter, when I added one and ran it
    The project didn't run, I got an error message.
    System.InvalidOperationException
    HResult=0x80131509
    Message=An error occurred creating the form. See Exception.InnerException for details. The error is: Failed to initialize because CategoryName is missing.
    Source=DiscMonitor
    StackTrace:
    at DiscMonitor.My.MyProject.MyForms.Create__Instance__[T](T Instance) in :line 190
    at DiscMonitor.My.MyProject.MyForms.get_Form1()
    at DiscMonitor.My.MyApplication.OnCreateMainForm() in D:\~VB Trials\DiscMonitor\My Project\Application.Designer.vb:line 35
    at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
    at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
    at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
    at DiscMonitor.My.MyApplication.Main(String[] Args) in :line 81

    This exception was originally thrown at this call stack:
    [External Code]

    Inner Exception 1:
    InvalidOperationException: Failed to initialize because CategoryName is missing.
    I removed the PerformanceCounter, and ran it again, no problem.
    I then added a PerformanceCounter again and ran it. Just got the error again.

    I don't understand why just adding a control should cause this problem.


    Poppa

    Windows 10 Home.

    Microsoft Visual Studio Community 2019
    Version 16.7.2
    VisualStudio.16.Release/16.7.2+30413.136
    Microsoft .NET Framework
    Version 4.8.03752

    Installed Version: Community

    Azure App Service Tools v3.0.0 16.7.532.28833
    Azure App Service Tools v3.0.0

    C# Tools 3.7.0-6.20412.3+d3c3a44a4e7ad31cc75c59be0d3df4a19ff33878
    C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

    Common Azure Tools 1.10
    Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

    IntelliCode Extension 1.0
    IntelliCode Visual Studio Extension Detailed Info

    NuGet Package Manager 5.7.0
    NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

    ProjectServicesPackage Extension 1.0
    ProjectServicesPackage Visual Studio Extension Detailed Info

    Visual Basic Tools 3.7.0-6.20412.3+d3c3a44a4e7ad31cc75c59be0d3df4a19ff33878
    Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

    Visual Studio Code Debug Adapter Host Package 1.0
    Interop layer for hosting Visual Studio Code debug adapters in Visual Studio
    Along with the sunshine there has to be a little rain sometime.

  2. #2
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,754

    Re: I have a problem with PerformanceCounter

    Why don't you show the code for the Performance Counter???????
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  3. #3

    Thread Starter
    PowerPoster Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Bottesford, North Lincolnshire, England.
    Posts
    2,423

    Re: I have a problem with PerformanceCounter

    Quote Originally Posted by dbasnett View Post
    Why don't you show the code for the Performance Counter???????
    I didn't realise I could.
    However, I've discovered how to supply the required data and all is now working.

    Poppa
    Along with the sunshine there has to be a little rain sometime.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width