Reputation: 890
I am trying to use the System.Management and System.Management.Instrumentation namespaces to get some information about the hardware my program is running on. However the classes under System.Management seems to be missing. I can import the namespace but it does not seem to contain anything except the. Instrumentation Namespace which does seem to have all its classes. I made sure that I was looking at the .net 4 framework API and it seems that it should be there. Any ideas?
Upvotes: 0
Views: 225
Reputation: 941615
A namespace can be scattered among multiple framework assemblies. That's certainly the case for System.Management.Instrumentation, it appears in System.Core.dll. Which is an assembly that was automatically added as a reference by the project template you selected to get your project started.
System.Core is pretty useful, it for example contains the Action<> and Func<> delegate types. Almost any program has a use for them so it got automatically added. The System.Management.Instrumentation namespace came along for the ride. This is not typical for .NET assemblies, but System.Core is somewhat special, it contains classes that were added in .NET 3.5 and they didn't want to mess with the .NET 2.0 and .NET 3.0 assemblies.
But to get something useful done with WMI, you'll need classes like ManagementQuery and they live in another assembly, System.Management.dll. This is not done automatically like it was for System.Core, WMI is not something that is commonly used. So it is optional and you have to ask for it.
Use Project + Add Reference to add System.Management
Use the MSDN Library to find out what assembly needs to be added to use a particular class, it is well documented at the top of the article. For ManagementQuery you'll see:
Namespace: System.Management
Assembly: System.Management (in System.Management.dll)
That last line is your cue.
Upvotes: 2