473,386 Members | 1,785 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,386 software developers and data experts.

VB.Net and Win32_NetworkAdapterConfiguration

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_NetworkAdapterConfigurati on
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
Aug 28 '08 #1
1 6151
I found the solution to the problem kind of. I had to turn Option Strict of.
I wrote a function that returns a string.

Dim strBuilder = appendCollection(queryObj("DNSDomainSuffixSearchOr der"))

Private Function appendCollection(ByVal coll As Array) As String
Dim str As String = ""
Dim strBuilder As String = ""
For Each str In coll
If strBuilder = "" Then
strBuilder = str
Else
strBuilder = strBuilder & "," & str
End If
Next
Return strBuilder
End Function

"wh******@noemail.noemail" wrote:
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_NetworkAdapterConfigurati on
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
Sep 3 '08 #2

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

Similar topics

3
by: shawkee | last post by:
Anyone knows how to read the MAC address on the network card in .NET?
2
by: Paul Gronka | last post by:
I've got a VB.NET windows application (written in VS .NET 2003) that makes a call to WMI for retrieving the MAC Address from the client's PC. It works on 4 out of the 5 PC's tested so far. All...
3
by: LK | last post by:
Can PLEASE SOMEONE HELP me how to enumerate local network interfaces (i.e ip addresses, dns, etc.) with csharp. I need the type of information that would come up when typing ipconfig /all ...
0
by: James Jenkins | last post by:
Hi - I am writing a network monitor application. I am using WMI class's - Win32_NetworkAdapter & Win32_NetworkAdapterConfiguration - I am also using the...
2
by: Paul Steele | last post by:
I have some code that uses the WMI class win32_NetworkAdapterConfiguration to access each adapter in a system. On 99% of the systems the code seems to work. On a very few the code fails when trying...
1
by: Mark Hollander | last post by:
Hi, I am using the WMI management object to obtain values about the network cards installed on the system. The MSDN tells me the following class Win32_NetworkAdapterConfiguration :...
3
by: Mark Prenter | last post by:
Hello, I'm trying to find a way to retrieve the MAC address from a network card in a Visual C++ .NET managed application. I've found some examples in C#, but I just can't get them to work in C++....
4
by: Jason | last post by:
Hello I'm writting a c# app, and I've got a computer that has two built in nic's. One is a Intel Pro/100 and the other is a Intel Pro/1000. I want to get the mac and ip address assigned to...
0
by: wmihelpme | last post by:
Hi All, I have written a WMI Program which changes the network settings like ip address, subnet mask, gateway and dns addresses for given adapter number. when I call that function for adapter...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

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.