Results 1 to 6 of 6

Thread: Obsolete property

  1. #1

    Thread Starter
    Fanatic Member Arve K.'s Avatar
    Join Date
    Sep 2008
    Location
    Kyrksæterøra, Norway
    Posts
    518

    Obsolete property

    Hi,

    I got this warning:
    Warning 1 'Public Property Address() As Long' is obsolete: 'This property has been deprecated. It is address family dependent. Please use IPAddress.Equals method to perform comparisons. http://go.microsoft.com/fwlink/?linkid=14202' E:\_Visual Studio_\2008\VB\Pinger\classPinger\pingerbib.vb 167 38 pingerbib
    with this code:
    Code:
    Dim ipaddress As IPAddress
    Dim ip As Integer = CInt(Net.IPAddress.Parse(IP_adresse).Address
    Anyone know what the correct code is??
    Last edited by Arve K.; Sep 27th, 2009 at 06:40 PM.
    Arve K.

    Please mark your thread as resolved and add reputation to those who helped you solve your problem
    Disclaimer: I am not a professional programmer

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Obsolete property

    First up, read the error message. It says that the Address property is what's obsolete, not the part that you've underlined. It also suggests what you should be doing. It even says "please", which is rather polite for an error message, don't you think?

    That said, I can't tell from your code what you're actually trying to accomplish, so I can't say for sure how you should accomplish it. An explanation of what you're actually trying to do is always a good idea if you want us to tell you what code to use to accomplish it.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Fanatic Member Arve K.'s Avatar
    Join Date
    Sep 2008
    Location
    Kyrksæterøra, Norway
    Posts
    518

    Re: Obsolete property

    Hey, I must have forgotten about this thread

    But to help you help me, here's some more of the code
    vb Code:
    1. Private Declare Function SendARP Lib "iphlpapi.dll" (ByVal DestIP As Integer, ByVal SrcIP As Integer, ByRef pMacAddr As Long, ByRef PhyAddrLen As Integer) As Integer
    2.        
    3. Public Overrides Function Execute(ByVal ipAddress As IPAddress) As ColumnValue
    4.             Dim ResultatOUI As String = Nothing
    5.  
    6.             Try
    7.                 Dim ip As Integer = CInt(Net.IPAddress.Parse(ipAddress.ToString).Address)
    8.  
    9.                 Dim mem As Long
    10.                 Dim ret As Integer = SendARP(ip, 0, mem, 6)
    11.                 Dim ab() As Byte = BitConverter.GetBytes(mem)
    12.  
    13.                 Dim OUI As String = BitConverter.ToString(ab, 0, 3) '<-- forandre 3 til 6 for å få hele mac-adressen
    14.  
    15.                 'PS: OUI = mac address...
    16.  
    17.                 Using sr As IO.StreamReader = New IO.StreamReader(Application.StartupPath & "\ieee_oui.txt")
    18.                     Dim line As String
    19.                     Do
    20.                         line = sr.ReadLine()
    21.                         If line.Contains(OUI) Then
    22.  
    23.                             ResultatOUI = line.Remove(0, 18)
    24.  
    25.                         End If
    26.  
    27.                     Loop Until line Is Nothing
    28.                     sr.Close()
    29.  
    30.                 End Using
    31.  
    32.  
    33.             Catch ex As Exception
    34.                 'do nothing
    35.             End Try
    36.  
    37.             Return New ColumnValue(ColumnIndex, ResultatOUI)
    38.  
    39.         End Function

    The purpose of this code is this:
    Let us say I have a device on my network with ip 192.168.100.100. I then use this code to get that devices mac address. I use the mac address to get the device manufacturer.

    The code works fine, it's not that, but I get this warning as mentioned earlier. When I change it to..:

    vb Code:
    1. Dim ip As Integer = CInt(Net.IPAddress.Parse(ipAddress.ToString).Equals)
    ...I get this error:
    Overload resolution failed because no accessible 'Equals' accepts this number of arguments.

    So I don't know if I should just leave it as it is, or maybe someone here might know what to do?
    Arve K.

    Please mark your thread as resolved and add reputation to those who helped you solve your problem
    Disclaimer: I am not a professional programmer

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Obsolete property

    You still haven't actually explained what the line of code that is giving you the messages is trying to do. The error message says:
    Please use IPAddress.Equals method to perform comparisons.
    Are you performing a comparison? If not the you wouldn't use Equals. Have you read the documentation for the IPAddress.Address property? Why is that not the obvious next step? That documentation says:
    This property is obsolete. Use GetAddressBytes.
    and kindly provides a link to the documentation for that property. The BitConverter class, which you're already using, can convert those Bytes to an Integer.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Fanatic Member Arve K.'s Avatar
    Join Date
    Sep 2008
    Location
    Kyrksæterøra, Norway
    Posts
    518

    Re: Obsolete property

    Sorry jmcilhinney, but I give up. I understand that you're trying to help me, but I just can't seem to find an answer. And as long as the code works, I won't give it any more thought.

    PS: The codeline changes the (example) string 192.168.1.34 to integer 570534080
    Arve K.

    Please mark your thread as resolved and add reputation to those who helped you solve your problem
    Disclaimer: I am not a professional programmer

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Obsolete property

    What string? Your Execute method takes an IPAddress as an argument, not a String. You've already got an IPAddress object. Call its GetAddressBytes method to get a Byte array. Pass that array to BitConverter.ToInt32 to get an Integer.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width