W
whiggins
Hello
I used Code Creator to generate the below vb.net code to pull some
information using the management namespace. I only posted a small section of
the code but it will represent the problem I am having.
I am using Dot Net
Framework version 2.0 and the bleow code generates an error.
This section causes the error
Dim arrDNSDomainSuffixSearchOrder As String()
arrDNSDomainSuffixSearchOrder = queryObj("DNSDomainSuffixSearchOrder")
The error message states: Value of type 'String' cannot be converted to
'1-dimensional array of String'
I am a bit new to coding in windows environment so any help would be greatly
appreciated.
Imports System
Imports System.Management
Imports System.Windows.Forms
Namespace WMISample
Public Class MyWMIQuery
Public Overloads Shared Function Main() As Integer
Try
Dim searcher As New ManagementObjectSearcher( _
"root\CIMV2", _
"SELECT * FROM Win32_NetworkAdapterConfiguration")
For Each queryObj As ManagementObject in searcher.Get()
Console.WriteLine("-----------------------------------")
Console.WriteLine("Win32_NetworkAdapterConfiguration
instance")
Console.WriteLine("-----------------------------------")
If queryObj("DNSDomainSuffixSearchOrder") Is Nothing Then
Console.WriteLine("DNSDomainSuffixSearchOrder: {0}",
queryObj("DNSDomainSuffixSearchOrder"))
Else
Dim arrDNSDomainSuffixSearchOrder As String()
arrDNSDomainSuffixSearchOrder =
queryObj("DNSDomainSuffixSearchOrder")
For Each arrValue As String In
arrDNSDomainSuffixSearchOrder
Console.WriteLine("DNSDomainSuffixSearchOrder:
{0}", arrValue)
Next
End If
Next
Catch err As ManagementException
MessageBox.Show("An error occurred while querying for WMI
data: " & err.Message)
End Try
End Function
End Class
End Namespace
I used Code Creator to generate the below vb.net code to pull some
information using the management namespace. I only posted a small section of
the code but it will represent the problem I am having.
I am using Dot Net
Framework version 2.0 and the bleow code generates an error.
This section causes the error
Dim arrDNSDomainSuffixSearchOrder As String()
arrDNSDomainSuffixSearchOrder = queryObj("DNSDomainSuffixSearchOrder")
The error message states: Value of type 'String' cannot be converted to
'1-dimensional array of String'
I am a bit new to coding in windows environment so any help would be greatly
appreciated.
Imports System
Imports System.Management
Imports System.Windows.Forms
Namespace WMISample
Public Class MyWMIQuery
Public Overloads Shared Function Main() As Integer
Try
Dim searcher As New ManagementObjectSearcher( _
"root\CIMV2", _
"SELECT * FROM Win32_NetworkAdapterConfiguration")
For Each queryObj As ManagementObject in searcher.Get()
Console.WriteLine("-----------------------------------")
Console.WriteLine("Win32_NetworkAdapterConfiguration
instance")
Console.WriteLine("-----------------------------------")
If queryObj("DNSDomainSuffixSearchOrder") Is Nothing Then
Console.WriteLine("DNSDomainSuffixSearchOrder: {0}",
queryObj("DNSDomainSuffixSearchOrder"))
Else
Dim arrDNSDomainSuffixSearchOrder As String()
arrDNSDomainSuffixSearchOrder =
queryObj("DNSDomainSuffixSearchOrder")
For Each arrValue As String In
arrDNSDomainSuffixSearchOrder
Console.WriteLine("DNSDomainSuffixSearchOrder:
{0}", arrValue)
Next
End If
Next
Catch err As ManagementException
MessageBox.Show("An error occurred while querying for WMI
data: " & err.Message)
End Try
End Function
End Class
End Namespace