Click here to Skip to main content
13,089,246 members (65,491 online)
Rate this:
Please Sign up or sign in to vote.
See more:

Here is my code.

String dnsServerName = "localhost";
            ManagementScope scope =
               new ManagementScope(@"\\" + dnsServerName + "\\root\\MicrosoftDNS");
            ManagementClass cmiClass =
               new ManagementClass(scope,
                                   new ManagementPath("MicrosoftDNS_AType"),
            ManagementBaseObject inParams =
            inParams["DnsServerName"] = this.ServerName;
            inParams["ContainerName"] = zone;
            inParams["OwnerName"] = hostName + "." + zone;
            inParams["IPAddress"] = iPAddress;
            cmiClass.InvokeMethod("CreateInstanceFromPropertyData", inParams, null);

I was able to reference 'ManagementClass' successfully.

But I have googled and googled but I don't understand how to reference wmiClass correctly.

Please can some one help me.

Posted 1-May-13 2:05am
M.R. Inc1.1K
Not clear what do you mean by referencing a class. What is the problem, exactly?
M.R. Inc 1-May-13 10:46am
In C# you reference DLLs so that you can control certain aspects of the computer.

Like you would reference a DLL to change windows colours.

In my case.

I do not understand what to do to reference WmiClass so that I can control my DNS server.

OK, you demonstrated that you poorly understand what is referencing the DLL, thank you. Essentially, you reference assembly, no "DLL", which is meaningful in .NET (just a file type). What is "reference a class"? OK, did you add the System.Management reference?
M.R. Inc 1-May-13 11:11am
Yes, that was referenced successfully but the WmiClass I don't know what to do.

What do you men by that? It depends on what you want to do. Does it compile? If not, what's the error?
M.R. Inc 1-May-13 11:15am
The name 'wmiClass' does not exist in the current context
ganesh.rit 1-May-13 11:28am
in your case you should use cmiClass instead wmiClass
This is because you declare "wmiClass" and spelled "cmiClass" below. Come on, Visual Studio points it out precisely. You need to learn how to read it. And please, read the chapter on .NET assemblies. This is one of the most fundamental things.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

wmiClass changed to cmiClass

Thank you Sergey and Ganesh!! :)
ganesh.rit 1-May-13 11:32am
Wonder in this world ..... Ganesh answers the question and Sergey gets thank you :P
M.R. Inc 1-May-13 11:36am
Sorry mate!!

I saw Sergeys name and missed yours

:D Thanks!
richcb 1-May-13 11:38am
Why did you post a comment as a solution to your own question? Be careful not to do that as it can be construed as abuse.
M.R. Inc 1-May-13 11:58am
Well there was no other way to take Ganeshes reply as an answer...
richcb 1-May-13 12:00pm
I understand. I just wanted to give you a heads up so you would avoid being reported as an abuser in the future.
M.R. Inc 1-May-13 12:01pm
richcb 1-May-13 12:02pm
No problem.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.170813.1 | Last Updated 1 May 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100