Click here to Skip to main content
15,888,283 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi there!
I am working on a C# application that monitor CPU Usage. The raw data must flow through a Graph and display on a form application. I'm quite new with C# and this error "Does not contain a definition for..." bullies me for a few days now haha. I've done tons of research on the problem, however I still don't find any solution(s) that I understand/snap.
The Problem lies at "CpuUsage.ChartAreas[0]"Were it has been marked '<--- Error'

Some code you will find also shows "Does not contain a definition for 'CpuUsage' and no extension method 'CpuUsage' accepting a first argument of type 'GraphMeter.Form1' could be found (are you missing a using directive or an assembly reference?)"

Solved(Thanks)
Posted
Updated 28-Jan-15 23:29pm
v3
Comments
sashje- 29-Jan-15 3:50am    
Not easy to help you without knowing what the class CpuUsage is implemented as. And is the Page_Load correct? Shouldn't the second parameter be EventArgs?
Eric@Fibonacci 29-Jan-15 4:46am    
Hi Sashje,
Yes the parameter have been corrected to EventArgs e.
Many Thanks.

1 solution

Whenever you are trying to sort out problems in your code start at the very first error reported not somewhere in the middle!
The first error reported is not on that line at all - it's on
public void Form1_Load(object sender, CpuUsage e)
and states
Quote:
The type or namespace name 'CpuUsage' could not be found (are you missing a using directive or an assembly reference?)

Steps you can take to resolve your problem...

1. Have you spelled "CpuUsage" correctly - it's not CPUUsage or Cpuusage for example.

2. Have you referenced the DLL or included the class file for CpuUsage in your project?

3. What is the namespace for CpuUsage and should you have included it with a using

4. If none of those work try "Clean Solution"

5. If that still doesn't work try removing the reference and putting it back

6. Check that whatever installed the CpuUsage class is properly installed (e.g. is the DLL properly registered)

I'll repeat my earlier advice - always start to deal with build errors with error number 1 - many of the others will simply disappear after it is fixed
 
Share this answer
 
Comments
Eric@Fibonacci 29-Jan-15 4:44am    
Hi CHill60,
Thanks for the advice! I've managed to sort out the problem at Form1_Load and the parameter CpuUsage e. Thanks for the steps though. Save allot of time.
CHill60 29-Jan-15 5:39am    
Those steps have gotten me through several puzzling moments! I really had to think about them before I wrote them down because it's stuff I do automatically without thinking... usually after I've groaned and called myself a "donkey" :-)
Eric@Fibonacci 29-Jan-15 6:57am    
Hahahaha same here!, Yes I can imagine. In my case, on some occasions however I end up with spaghetti code, so I'll definitely gonna keep using them more often. Thanks again for the fast solution Chill60!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900