Click here to Skip to main content
15,889,116 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello

Here is my code.

C#
String dnsServerName = "localhost";
            ManagementScope scope =
               new ManagementScope(@"\\" + dnsServerName + "\\root\\MicrosoftDNS");

            scope.Connect();

            ManagementClass cmiClass =
               new ManagementClass(scope,
                                   new ManagementPath("MicrosoftDNS_AType"),
                                   null);

            ManagementBaseObject inParams =
                wmiClass.GetMethodParameters("CreateInstanceFromPropertyData");

            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.

Thanks
Posted
Comments
Sergey Alexandrovich Kryukov 1-May-13 10:40am    
Not clear what do you mean by referencing a class. What is the problem, exactly?
—SA
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.

Thanks
Sergey Alexandrovich Kryukov 1-May-13 11:08am    
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?
—SA
M.R. Inc 1-May-13 11:11am    
Yes, that was referenced successfully but the WmiClass I don't know what to do.

Thanks
Sergey Alexandrovich Kryukov 1-May-13 11:13am    
What do you men by that? It depends on what you want to do. Does it compile? If not, what's the error?
—SA

1 solution

wmiClass changed to cmiClass

Thank you Sergey and Ganesh!! :)
 
Share this answer
 
v2
Comments
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!
Richard C Bishop 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...
Richard C Bishop 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.

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



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