.Net System.Management

R

Rene

Please help!

The following C# code retrieves the MAC address. The code works great in a
regular windows XP system but it does not work on an XP Embedded OS image
running the embedded version of .Net. I am probably missing one or two files
but I am not sure which ones, Could someone help me???

---------------------------------------------------------------

string mdac = "";

System.Management.ManagementClass mc = new
System.Management.ManagementClass("Win32_NetworkAdapterConfiguration");
System.Management.ManagementObjectCollection moc = mc.GetInstances();

foreach(System.Management.ManagementObject mo in moc)
{
if((bool)mo["IPEnabled"] == true)
mdac = mo["MacAddress"].ToString();
mo.Dispose();
}
return mdac;

---------------------------------------------------------------
 
N

Nicholas Paldino [.NET/C# MVP]

Rene,

What happens when you run it? Do you get an exception? If so, which
one?
 
W

Willy Denoyette [MVP]

Are you sure WMI is (fully) supported on XP embedded?
If so could you check wheter the WMI class
"win32_NetworkAdapterConfiguration" is available, running wbemtest.exe

Willy.
 
R

Rene

This is part of the error message, can you tell wats wrong?

System.Management.ManagementException: Provider load failure
at
System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus
errorCode)
at System.Management.ManagementObjectEnumerator.MoveNext()
at System.Management.ManagementObjectCollection.get_Count()
at FitnessClubCustomSoftware.ObjectModel.CustomUtilities.GetMDACValue()
in c:\documents and settings\rene\desktop\fitnessclubcustomsoftware\object
model\customutilities.cs:line 205
at FitnessClubCustomSoftware.HMI.StartupForm.StartExercise(String
iButtonID) in c:\documents and
settings\rene\desktop\fitnessclubcustomsoftware\hmi\startupform.cs:line 171
at FitnessClubCustomSoftware.HMI.StartupForm.panel4_Click(Object sender,
EventArgs e) in c:\documents and
settings\rene\desktop\fitnessclubcustomsoftware\hmi\startupform.cs:line 208
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)
 
R

Rene

I found the utility but was no able to figure out how to get the
information, could you tell me what are the steps to follow once I open the
wbemtest.exe utility?



Thanks.

Willy Denoyette said:
Are you sure WMI is (fully) supported on XP embedded?
If so could you check wheter the WMI class
"win32_NetworkAdapterConfiguration" is available, running wbemtest.exe

Willy.

Rene said:
Please help!

The following C# code retrieves the MAC address. The code works great in a
regular windows XP system but it does not work on an XP Embedded OS image
running the embedded version of .Net. I am probably missing one or two
files
but I am not sure which ones, Could someone help me???

---------------------------------------------------------------

string mdac = "";

System.Management.ManagementClass mc = new
System.Management.ManagementClass("Win32_NetworkAdapterConfiguration");
System.Management.ManagementObjectCollection moc = mc.GetInstances();

foreach(System.Management.ManagementObject mo in moc)
{
if((bool)mo["IPEnabled"] == true)
mdac = mo["MacAddress"].ToString();
mo.Dispose();
}
return mdac;
 
J

Jeffrey Tan[MSFT]

Hi Rene,

Yes, I agree with Willy that you should first check whether the problem is
due to WMI support or the .Net WMI wrapper. So you need to use WMI Tester
tool wbemtest.exe.

To get more information about how to use this tool, please refer to:
"Walkthrough of WBEMTEST"
http://computerperformance.co.uk/Logon/WBMTEST.htm

Also, there is a section "WMI Tester (wbemtest.exe) Walkthrough" in the
article below:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnclinic/ht
ml/scripting06112002.asp

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

Jeffrey Tan[MSFT]

Hi Rene,

Does the community's reply make sense to you?

Please feel free to feedback. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
G

Guest

I ran into this same problem and found a solution that might be helpful to others. Apparently on our build of XP Embedded we did not include the "WMI Win32 Provider" package, this solved our problem. When the image built, make sure this package is added in.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top