| | |
2008 Warning in my code gethostbyname
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2008
Posts: 44
Reputation:
Solved Threads: 0
Hi when i use the following code i get a warning
'Public Shared Function GetHostByName(hostName As String) As System.Net.IPHostEntry' is obsolete: 'GetHostByName is obsoleted for this type, please use GetHostEntry instead.
now the code works and shows me the ip
'Public Shared Function GetHostByName(hostName As String) As System.Net.IPHostEntry' is obsolete: 'GetHostByName is obsoleted for this type, please use GetHostEntry instead.
VB.NET Syntax (Toggle Plain Text)
Dim host As System.Net.IPHostEntry = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName) 'gets the machines current IP
now the code works and shows me the ip
obsolete attribute means this method is old, and another one is used (GetHostEntry in your case)!
We use this attribute to tell developers who use our libraries that this method no longer use and use an alternative (the new one) + telling the compiler to raise warning or error if it used!
Understood?
We use this attribute to tell developers who use our libraries that this method no longer use and use an alternative (the new one) + telling the compiler to raise warning or error if it used!
Understood?
Last edited by Ramy Mahrous; Jan 15th, 2009 at 8:45 am.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
You didn't said I want just IPv4
To get it
I don't know VB.NET, I tried to convert it to VB.NET as much as I can.
To get it
vb.net Syntax (Toggle Plain Text)
dim host as IPHostEntry dim hostname as string hostname = "lmlmlaa"; host = Dns.GetHostEntry(hostname) For Each ip As IPAddress In host.AddressList if ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork MessageBox.Show(ip.ToString()) Next
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
•
•
Join Date: Mar 2008
Posts: 44
Reputation:
Solved Threads: 0
right i tried this
but it returen fe80::5efe:192.168.0.19%10 i just wanted 192.168.0.19 how do i get it to show that and not this fe80::5efe:192.168.0.19%10
VB.NET Syntax (Toggle Plain Text)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim myip As String = System.Net.Dns.GetHostAddresses(My.Computer.Name)(1).ToString().Trim ComboBox1.Items.Add(myip) End Sub
but it returen fe80::5efe:192.168.0.19%10 i just wanted 192.168.0.19 how do i get it to show that and not this fe80::5efe:192.168.0.19%10
Please concentrate in my answer and try this code, don't get me another pieces of code which I didn't write and say it doesn't work!!!!!!!!!
vb.net Syntax (Toggle Plain Text)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click dim host as IPHostEntry dim hostname as string hostname = My.Computer.Name host = Dns.GetHostEntry(hostname) For Each ip As IPAddress In host.AddressList if ip.AddressFamily = System.Net.Sockets.AddressFamily.InterNetwork ComboBox1.Items.Add(ip) end if Next
Last edited by Ramy Mahrous; Jan 15th, 2009 at 11:50 am.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
It doesn't return 3 items, seem you don't care! I tried my code before posting it works fine. I won't go on in this thread.
Excuse me!
Excuse me!
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
![]() |
Other Threads in the VB.NET Forum
- Previous Thread: rotating graphics
- Next Thread: pls advise - using access as database
| Thread Tools | Search this Thread |
.net 2005 2008 access account arithmetic array arrays basic bing button buttons c# center check checkbox code combobox component convert crystalreport data database datagrid datagridview date dissertation dissertations dropdownlist excel fade file-dialog folder ftp generatetags google gridview hardcopy images inline input insert intel internet listview mobile monitor ms net networking objects output passingparameters peertopeervideostreaming picturebox picturebox1 port print printing problem problemwithinstallation project remove save searchbox searchvb.net select serial server shutdown soap sorting survey table tcp temperature text textbox timer toolbox trim update updown user validation vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web winforms wpf






