473,383 Members | 1,868 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Error in a WMI Method

Hi, I was implementing in a program WinForm write in C# a method that change
the DNS Sufix of networkcard of PC, well I search in the .NET documenttion
and I found a class that allow this feature, the class
"Win32_NetworkAdapterConfiguration" with the method "SetDNSSuffixSearchOrder"
that receive when argument the string array "DNSDomainSuffixSearchOrder[]"
that it would have to be the new suffix. I write in code this implemetation
but I ever receive a error when it tries to change the suffix. My code is:

using System.Management;
public static void SetaSufixo()
{
ManagementClass suffix = new
ManagementClass("Win32_NetworkAdapterConfiguration ");

ManagementBaseObject newSuffix =
suffix.GetMethodParameters("SetDNSSuffixSearchOrde r");

newSuffix ["DNSDomainSuffixSearchOrder"] = "any value";

suffix.InvokeMethod ("SetDNSSuffixSearchOrder", newSuffix, null);

}

Somepeople has a ideia of as I I decide this problem?

Sorry my english =(

Tks

Bruno
--
C# .NET Developer
Nov 17 '05 #1
3 3814

"Bruno Renato" <Br*********@discussions.microsoft.com> wrote in message
news:59**********************************@microsof t.com...
Hi, I was implementing in a program WinForm write in C# a method that
change
the DNS Sufix of networkcard of PC, well I search in the .NET documenttion
and I found a class that allow this feature, the class
"Win32_NetworkAdapterConfiguration" with the method
"SetDNSSuffixSearchOrder"
that receive when argument the string array "DNSDomainSuffixSearchOrder[]"
that it would have to be the new suffix. I write in code this
implemetation
but I ever receive a error when it tries to change the suffix. My code is:

using System.Management;
public static void SetaSufixo()
{
ManagementClass suffix = new
ManagementClass("Win32_NetworkAdapterConfiguration ");

ManagementBaseObject newSuffix =
suffix.GetMethodParameters("SetDNSSuffixSearchOrde r");

newSuffix ["DNSDomainSuffixSearchOrder"] = "any value";

suffix.InvokeMethod ("SetDNSSuffixSearchOrder", newSuffix, null);

}

Somepeople has a ideia of as I I decide this problem?

Sorry my english =(

Tks

Bruno
--
C# .NET Developer


The "DNSDomainSuffixSearchOrder" property must be an array of strings!

Willy.
Nov 17 '05 #2
But when I implement this in the code?? I tried to use thus but also he did
not give certain:

newSuffix[1] ["DNSDomainSuffixSearchOrder"] = "any value";

or
string [] valor = new string [2];
valor[0] = "test";
newSuffix ["DNSDomainSuffixSearchOrder"] = "valor";

Which is the correct form?

Tks

Bruno Renato.
C# .NET Developer
"Willy Denoyette [MVP]" wrote:

"Bruno Renato" <Br*********@discussions.microsoft.com> wrote in message
news:59**********************************@microsof t.com...
Hi, I was implementing in a program WinForm write in C# a method that
change
the DNS Sufix of networkcard of PC, well I search in the .NET documenttion
and I found a class that allow this feature, the class
"Win32_NetworkAdapterConfiguration" with the method
"SetDNSSuffixSearchOrder"
that receive when argument the string array "DNSDomainSuffixSearchOrder[]"
that it would have to be the new suffix. I write in code this
implemetation
but I ever receive a error when it tries to change the suffix. My code is:

using System.Management;
public static void SetaSufixo()
{
ManagementClass suffix = new
ManagementClass("Win32_NetworkAdapterConfiguration ");

ManagementBaseObject newSuffix =
suffix.GetMethodParameters("SetDNSSuffixSearchOrde r");

newSuffix ["DNSDomainSuffixSearchOrder"] = "any value";

suffix.InvokeMethod ("SetDNSSuffixSearchOrder", newSuffix, null);

}

Somepeople has a ideia of as I I decide this problem?

Sorry my english =(

Tks

Bruno
--
C# .NET Developer


The "DNSDomainSuffixSearchOrder" property must be an array of strings!

Willy.

Nov 17 '05 #3

"Bruno Renato" <Br*********@discussions.microsoft.com> wrote in message
news:44**********************************@microsof t.com...
But when I implement this in the code?? I tried to use thus but also he
did
not give certain:

newSuffix[1] ["DNSDomainSuffixSearchOrder"] = "any value";

or
string [] valor = new string [2];
valor[0] = "test";
newSuffix ["DNSDomainSuffixSearchOrder"] = "valor";

Which is the correct form?

Tks

Bruno Renato.
C# .NET Developer


Make it...
string [] valor = new string [1];
valor[0] = "test";
newSuffix ["DNSDomainSuffixSearchOrder"] = valor;
or:
newSuffix ["DNSDomainSuffixSearchOrder"] = new string [1] {"Test"};

Willy.

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: josh dismukes | last post by:
/// here is the code i'm getting a parse error on the last line of the code which /// is </html> any help will be much appreciated. <?php session_start ();
2
by: John F Dutcher | last post by:
Can anyone comment on why the code shown in the Python error is in some way incorrect...or is there a problem with Python on my hoster's site ?? The highlites don't seem to show here...but line...
2
by: Fuzzyman | last post by:
I've written a CGI proxy that remotely fetches web pages. I use the urlopen function in CLientCookie which replaces (and ultimately uses) the urlopen function in urllib2. What I'd like to do is...
102
by: Skybuck Flying | last post by:
Sometime ago on the comp.lang.c, I saw a teacher's post asking why C compilers produce so many error messages as soon as a closing bracket is missing. The response was simply because the compiler...
8
by: Tom | last post by:
Hi I have an aspx page which has javascript to configure xmldata. I added breakpoint to the button method. When I click submit button, it did not go to those breakpoint and show the following...
8
by: Razak | last post by:
Hi, I have a class which basically do Impersonation in my web application. From MS KB sample:- ++++++++++++++++++++code starts Dim impersonationContext As...
10
by: Anthony England | last post by:
(sorry for the likely repost, but it is still not showing on my news server and after that much typing, I don't want to lose it) I am considering general error handling routines and have...
0
by: HKSHK | last post by:
This list compares the error codes used in VB.NET 2003 with those used in VB6. Error Codes: ============ 3: This Error number is obsolete and no longer used. (Formerly: Return without GoSub)...
5
by: csgraham74 | last post by:
Hi guys, Basically i have been developing in dotnet for a couple of years but ive had a few issues in regards to error handling. For example - I have a class that i call passing in a stored...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.