views:

171

answers:

2

Hi I'm having a problem implementing this method.

I have added using System.Management but the class still doesn't work.

The error is: Error 7 The type or namespace name 'ManagementBaseObject' could not be found (are you missing a using directive or an assembly reference?)

Help would be appreciated.

+1  A: 

did you add System.Management.dll as a reference?

msdn tells us more about where to find ManagementBaseObject:

Namespace: System.Management
Assembly: System.Management (in System.Management.dll)

Andreas Niedermair
I can't add .dll as a ref
Sandeep Bansal
can you add other assemblies?! typically the tab '.NET' does not contain the file extension for its assemblies (so it would be System.Management assembly you need to add in the .NET-tab)
Andreas Niedermair
Fixed and working, there was a problem with VS, just restarted the program and all is working.Thanks
Sandeep Bansal
+1  A: 

You are probably missing the assembly reference to System.Management.dll. The using statement just brings names into scope, to save you typing the prefix: it doesn't actually add a DLL reference.

Right-click your project's References folder and choose Add Reference. Go to the .NET tab of the resulting dialog, select System.Management and click OK.

itowlson
I can't use using System.Management.dll.Only using System.Management.Instrumentation
Sandeep Bansal
What do you see when you go into the Add Reference dialog, .NET tab? Is System.Management not there? Greyed out?
itowlson
Yes System.Management is there but I can't see or use System.Management.dll
Sandeep Bansal
That's fine. The Add Reference dialog just isn't showing the .dll extension (because everything in the list is a DLL so it would be a waste of space). Click System.Management in the dialog box, and click OK.
itowlson
I've done that but still I can't use ManagementBaseObject
Sandeep Bansal
Weird, that should work. I think you'd better post a code fragment and a screenshot of your References folder so we can see what's going on.
itowlson