Help: Getting the IPAddresses of Computers in a Workgroup
-
Help please.. Can anyone there resolve this? -Sample Code- System.Net ... 'let's assume there are other codes here dim Addr as IPAddress With DNS.GetHostByName() Addr = System.Net.IPAddress(.AddressList(0).Address) End With ... That should have been the way to get the IP Addresses, but in VBNET 2003 the line: "(.AddressList(0).Address)" is obsolete.. Anyone knows the new way?? Be grateful for the help.. Thanks in advance..
-
Help please.. Can anyone there resolve this? -Sample Code- System.Net ... 'let's assume there are other codes here dim Addr as IPAddress With DNS.GetHostByName() Addr = System.Net.IPAddress(.AddressList(0).Address) End With ... That should have been the way to get the IP Addresses, but in VBNET 2003 the line: "(.AddressList(0).Address)" is obsolete.. Anyone knows the new way?? Be grateful for the help.. Thanks in advance..
Since you got that "obsolete" message, you're using VB.NET 2005. Check out the Dns class and its GetHostAddesses[^] method.
Dave Kreskowiak Microsoft MVP - Visual Basic
-
Since you got that "obsolete" message, you're using VB.NET 2005. Check out the Dns class and its GetHostAddesses[^] method.
Dave Kreskowiak Microsoft MVP - Visual Basic
-
Hmm.. but i'm using Visual Studio 2003.. anyways do u know another way? Hope u can help me.. i'm still lookin for another way though.. Thanks
There's only two methods. The one you posted in your code, which gave you the obsolete message, and the one in the .NET Framework 2.0. The .NET Framework 1.0 and 1.1 both use the same Dns class. It was nearly completely re-written for .NET 2.0. This[^] is the docs for the 1.0/1.1 version of the Dns class.
Dave Kreskowiak Microsoft MVP - Visual Basic
-
There's only two methods. The one you posted in your code, which gave you the obsolete message, and the one in the .NET Framework 2.0. The .NET Framework 1.0 and 1.1 both use the same Dns class. It was nearly completely re-written for .NET 2.0. This[^] is the docs for the 1.0/1.1 version of the Dns class.
Dave Kreskowiak Microsoft MVP - Visual Basic
" 'Public Property Address() AS Long' is obsolete: 'IPAddress.Address is address family dependant, use equals method for comparison.' " That's the whole statement of the error. My framework is 1.1, and it cant be 2.0 coz im not using VS2005.. but can i use Framework 2.0 with VS2003? i haven't found another way..and how can i set the client to look for any server running in any of the pc in a network. Like if i run a Server or the listener on PC4, the client is on PC1, without specifying the IPAddress where the Server file is running.. if i transfer the server to PC8, the client can still detect it. Something like that. I'm actually new on using System.Net and im just lookin on examples available in the web. I have tried the basics of Server-Client, the problem is the one i stated above. and the client issue.. thanks
-
" 'Public Property Address() AS Long' is obsolete: 'IPAddress.Address is address family dependant, use equals method for comparison.' " That's the whole statement of the error. My framework is 1.1, and it cant be 2.0 coz im not using VS2005.. but can i use Framework 2.0 with VS2003? i haven't found another way..and how can i set the client to look for any server running in any of the pc in a network. Like if i run a Server or the listener on PC4, the client is on PC1, without specifying the IPAddress where the Server file is running.. if i transfer the server to PC8, the client can still detect it. Something like that. I'm actually new on using System.Net and im just lookin on examples available in the web. I have tried the basics of Server-Client, the problem is the one i stated above. and the client issue.. thanks
OK. So you're using 2003. No, you can't use .NET 2.0 with VS.NET 2003. It will only work with VS.NET 2005. Remove the
.Address
part of the line. You don't need it unless you want the IP address returned as a 32-bit number. This isn't supported in .NET 2.0, so don't use it. This code works just fine:Dim hostInfo As IPHostEntry = Dns.GetHostByName("www.yahoo.com") Dim address As IPAddress() = hostInfo.AddressList
Dim al As String() = hostInfo.Aliases
Debug.WriteLine("Host name : " + hostInfo.HostName)
Debug.WriteLine(ControlChars.Cr + "Aliases : ")
Dim index As Integer
For index = 0 To al.Length - 1
Debug.WriteLine(al(index))
Next index
Debug.WriteLine(ControlChars.Cr + "IP address list : ")
For index = 0 To address.Length - 1
Debug.WriteLine(address(index))
Next indexand was taken directly out of the docs for
Dns.GetHostByName
in the .NET 1.0/1.1 docs.Dave Kreskowiak Microsoft MVP - Visual Basic