M
moondaddy
I have a smartclient app in vb.net 1.1. In the app's startup form's
form_load event I have some code that gets the machine's MAC address which I
think is the culprit here. The code runs fine on my dev machine and as far
as I know it runs OK on the client machines it gets installed on. I now
have a test machine which is a brand new dell with WinXP sp2 and ALL windows
updates (including the .net framework 1.1 and all relate SPs and updates,
but not .net 2.0). I have not installed MS Office or any other apps on it
so it is a very clean machine. my smart client app installs OK on the test
machine, but when it starts up I get the following Error:
<<<
System.Management.ManagementException: COM object that has been separated
from its underlying RCW can not be used.
System.Runtime.InteropServices.InvalidComObjectException: COM object that
has been separated from its underlying RCW can not be used. at
system.Management.IEnumWbemClassObject.Clone_(IEnumWbemClassObject&
ppEnum) at system.Management.ManagementObjectCollection.GetEnumerator()
and here's the code where I think the problem is, however, I'm not getting
the exact line of code in the exception:
Dim mc As System.Management.ManagementClass
Dim mo As System.Management.ManagementObject
mc = New
System.Management.ManagementClass("Win32_NetworkAdapterConfiguration")
Dim moc As System.Management.ManagementObjectCollection = mc.GetInstances()
Dim found As Boolean
For Each mo In moc
If CType(mo.Item("IPEnabled"), Boolean) = True Then
If mo.Item("MacAddress").ToString() = "bla bla bla" Then
found = True
Exit For
End If
End If
Next
Can anyone tell me why I would get this error on a clean machine? And how
should I write this correctly to avoid this error?
form_load event I have some code that gets the machine's MAC address which I
think is the culprit here. The code runs fine on my dev machine and as far
as I know it runs OK on the client machines it gets installed on. I now
have a test machine which is a brand new dell with WinXP sp2 and ALL windows
updates (including the .net framework 1.1 and all relate SPs and updates,
but not .net 2.0). I have not installed MS Office or any other apps on it
so it is a very clean machine. my smart client app installs OK on the test
machine, but when it starts up I get the following Error:
<<<
System.Management.ManagementException: COM object that has been separated
from its underlying RCW can not be used.
System.Runtime.InteropServices.InvalidComObjectException: COM object that
has been separated from its underlying RCW can not be used. at
system.Management.IEnumWbemClassObject.Clone_(IEnumWbemClassObject&
ppEnum) at system.Management.ManagementObjectCollection.GetEnumerator()
and here's the code where I think the problem is, however, I'm not getting
the exact line of code in the exception:
Dim mc As System.Management.ManagementClass
Dim mo As System.Management.ManagementObject
mc = New
System.Management.ManagementClass("Win32_NetworkAdapterConfiguration")
Dim moc As System.Management.ManagementObjectCollection = mc.GetInstances()
Dim found As Boolean
For Each mo In moc
If CType(mo.Item("IPEnabled"), Boolean) = True Then
If mo.Item("MacAddress").ToString() = "bla bla bla" Then
found = True
Exit For
End If
End If
Next
Can anyone tell me why I would get this error on a clean machine? And how
should I write this correctly to avoid this error?