Windows Develop Bookmark and Share   
 index > Windows Forms General > Unknown Error can't figure it out
 

Unknown Error can't figure it out

Coding Skill : Programmed in C++ , Knows OOPs concept.
VC# Skill:
Just started VC# coding , Novice
IDE : Microsoft Visual Studio 2005.
Code: C-Sharp , C#

I'm working on a simple notepad program , which clear the text on the textbox,

it was working fine tomorrow ,but today when i re-build the project ,it did not compiled,

BackColor has encountered a problem and needs to close. We are sorry for the inconvenience.
Error:

Send Error report to microsoft,

I choosed to debug the program


On clicking the error it shows this error:

((System.ComponentModel.ISupportInitialize)(this.performanceCounter1)).EndInit();

and a window which points to the above line and says "Failed to initialize because CategoryName is missing."

you can download the file:

http://www.mediafire.com/file/uxdmgzzjyel/BackColor.zip
Abaf  Sunday, September 27, 2009 11:10 AM
Hi Abaf

At the bottom of the form design view there's a tray which contains component-derived controls, eg menuStrip1 and performanceCounter1.
Select performanceCounter1. Press F4 to direct focus to the Properties Window. In the Properties Window select the CategoryName and set it to [whatever you initially had in mind to monitor]. Same with CounterName. These modifications will update the designer generated code for you.

If you did not initially have any need for the performance counter, simply remove the control from the form designer tray.

Hope that helps.

  • Marked As Answer byAbaf Monday, September 28, 2009 9:55 PM
  •  
Wole Ogunremi  Monday, September 28, 2009 4:54 PM
Have a look at this thread.
Basically, you need to specify a valid category and counter. You can select these from performanceCounter1's properties window.
Wole Ogunremi  Sunday, September 27, 2009 11:30 AM
Have a look at this thread .
Basically, you need to specify a valid category and counter. You can select these from the properties window.
well thanks
But its for VB.Net
Abaf  Sunday, September 27, 2009 11:36 AM

One of the advantages is that C# and VB only differ in syntax, but both use exactly the same classes and types and thus can be easily translated:

[Visual Basic] 
Dim PC As New PerformanceCounter()
PC.CategoryName = "Process" You forgot this
PC.CounterName = "Private Bytes"
PC.InstanceName = "Explorer"
MessageBox.Show(PC.NextValue().ToString())


[C#]
PerformanceCounter pc = new PerformanceCounter();
pc.CategoryName = "Process"; // <== You forgot this
pc.CounterName = "Private Bytes";
pc.InstanceName = "Explorer";
MessageBox.Show(pc.NextValue().ToString());

Geert van Horrik - CatenaLogic
Visit my blog: http://blog.catenalogic.com

Looking for a way to deploy your updates to all your clients? Try Updater!
  • Marked As Answer bynobugzMVP, ModeratorSunday, September 27, 2009 2:36 PM
  • Unmarked As Answer byAbaf Monday, September 28, 2009 2:55 PM
  •  
Geert van Horrik  Sunday, September 27, 2009 11:42 AM
I hope this will work tell me where to put the code :
pc.CategoryName = "Process"
;
// <== You forgot this




in which file

Form1.cs
Form1.Designer.cs
Program.cs
  • Edited byAbaf Sunday, September 27, 2009 3:31 PMformatting
  •  
Abaf  Sunday, September 27, 2009 3:30 PM
The changes go in the designer.cs file. However, you really shouldn't modify this file by hand since it is autogenerated and your changes may be overwritten if it is regenerated. This is why I initially suggested to select your performanceCounter in the form design view, and make your changes in the property window.
Wole Ogunremi  Monday, September 28, 2009 3:40 PM
please note I'm "VC# Skill: Just started VC# coding , Novice"

two solutions to my problem:

1) As you have said to use the design view to fix the problem please,I assume you are referring to adjust the property by using "Property Explorer"
so which "Control" property shud I change , is it the form property...?

kindly guide like this
form>property>text>change to "etc "

2)OR do changes in designer.cs

So,kindly tell me where to put the code:

namespace BackColor
{
    partial class Form1
    {

///// PUT THE CODE HERE ???///
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
///// PUT THE CODE HERE ???///
           
        }

        #region Windows Form Designer generated code

       
        private void InitializeComponent()
        {
           ///// PUT THE CODE HERE ???///
            
           //I RIPPED THE CODE
//IT CONTAINED AUTOGENERATED CODE RELATED TO //RADIO_BUTTON AND MENUSTRIP ETC

System.Windows.Forms.ToolStripMenuItem();
            this.performanceCounter1 = new 

System.Diagnostics.PerformanceCounter();
            this.menuStrip1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)

            //
            // Form1
            //
//CODE RIPPED
///// PUT THE CODE HERE ???///

        }

        #endregion
//CODE RIPPED
///// PUT THE CODE HERE ???///
      
    }
}



in which Block ?:

I hope I'm clear in explaining my question and confusion..
Kindly guide me :-)



  • Edited byAbaf Monday, September 28, 2009 4:29 PMformatting
  • Edited byAbaf Monday, September 28, 2009 4:28 PMformatting
  •  
Abaf  Monday, September 28, 2009 4:27 PM
Hi Abaf

At the bottom of the form design view there's a tray which contains component-derived controls, eg menuStrip1 and performanceCounter1.
Select performanceCounter1. Press F4 to direct focus to the Properties Window. In the Properties Window select the CategoryName and set it to [whatever you initially had in mind to monitor]. Same with CounterName. These modifications will update the designer generated code for you.

If you did not initially have any need for the performance counter, simply remove the control from the form designer tray.

Hope that helps.

  • Marked As Answer byAbaf Monday, September 28, 2009 9:55 PM
  •  
Wole Ogunremi  Monday, September 28, 2009 4:54 PM
well i could not access the Designer view...because it shows Red warning error reffering to the code i put in it

1) so i removed the code
pc.CategoryName = "Process"
;
back from designer,cs

2) commented thie statement ,to which Error List window was referring to
//((System.ComponentModel.ISupportInitialize)(this.performanceCounter1)).EndInit();
well my problem solved,but kindly answer this strange thing

Q) The app was running fine previously ,but when the next day I compiled it again without an changes it showed up with error...why it was running fine previously...?
Abaf  Monday, September 28, 2009 10:01 PM

You can use google to search for other answers

Custom Search

More Threads

• Can someone explain this datagridview behavior?
• ContextMenuStrip Display Capability
• not able to locate line of code geberating the pb
• HTMLDocument question
• Weird isue with Bitmap Images and Tooltips
• Printing Forms with scrollbars
• processbar, how to identify ProgressPercentage
• Cannot write to a richtextbox
• Multiple UI Threads on the same form?
• ON_REGISTERED_MESSAGE