| | |
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
Views: 1416 | Replies: 14
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
.net .net2008 2008 access advanced application array basic beginner browser button buttons center click client code combo convert cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic eclipse excel exists fade filter forms function html images input lib listview map mobile module msaccess net number objects open panel pdf picturebox picturebox2 port position print printing problem read regex remove richtextbox right-to-left save search searchvb.net serial settings shutdown socket sorting sqldatbase sqlserver survey temperature textbox timer timespan transparency txttoxmlconverter usercontol validation vb vb.net vb2008 vba vbnet visual visualbasic visualbasic.net visualstudio.net visualstudio2008 web webbrowser winforms winsock wpf wrapingcode xml year






