Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Why Dns.Resolve Method in C# is obsolete ? Workaround?

Why Dns.Resolve Method in C# is obsolete ? Workaround?

Scheduled Pinned Locked Moved C#
csharpcomsysadminhelpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    ksaw123
    wrote on last edited by
    #1

    I am trying to write a small function in C# by passing this DNS name www.google.com And the function should return the host IP , it is like querying DNS server! I wrote the following program , but it seems there this Warning Warning 1 'System.Net.Dns.Resolve(string)' is obsolete: 'Resolve is obsolete for this type, please use GetHostEntry instead. http://go.microsoft.com/fwlink/?linkid=14202' D:\CoDoNS\WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs 26 20 WindowsFormsApplication1 Using System; Using Sytem.Net; namespace BuilderExamples { class BuilderIPAddress { static void Main(string[] args) { try { IPHostEntry iphe = Dns.Resolve("www.google.com"); foreach (IPAddress addr in iphe.AddressList) { Console.WriteLine("AddressFamily: " + addr.AddressFamily.ToString()); Console.WriteLine("Address: " + addr.ToString()); } } catch (Exception e) { Console.WriteLine("Error: " + e.ToString()); } } } } Why Dns.Resolve Method in C# is obsolete ? is the a workaround to get that function done? Thanks

    M 1 Reply Last reply
    0
    • K ksaw123

      I am trying to write a small function in C# by passing this DNS name www.google.com And the function should return the host IP , it is like querying DNS server! I wrote the following program , but it seems there this Warning Warning 1 'System.Net.Dns.Resolve(string)' is obsolete: 'Resolve is obsolete for this type, please use GetHostEntry instead. http://go.microsoft.com/fwlink/?linkid=14202' D:\CoDoNS\WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs 26 20 WindowsFormsApplication1 Using System; Using Sytem.Net; namespace BuilderExamples { class BuilderIPAddress { static void Main(string[] args) { try { IPHostEntry iphe = Dns.Resolve("www.google.com"); foreach (IPAddress addr in iphe.AddressList) { Console.WriteLine("AddressFamily: " + addr.AddressFamily.ToString()); Console.WriteLine("Address: " + addr.ToString()); } } catch (Exception e) { Console.WriteLine("Error: " + e.ToString()); } } } } Why Dns.Resolve Method in C# is obsolete ? is the a workaround to get that function done? Thanks

      M Offline
      M Offline
      Mirko1980
      wrote on last edited by
      #2

      Well, the warning message is already giving you the answer. Use Dns.GetHostEntry: IPHostEntry iphe = Dns.GetHostEntry("www.google.com");

      K 1 Reply Last reply
      0
      • M Mirko1980

        Well, the warning message is already giving you the answer. Use Dns.GetHostEntry: IPHostEntry iphe = Dns.GetHostEntry("www.google.com");

        K Offline
        K Offline
        ksaw123
        wrote on last edited by
        #3

        it works but what is meant by "obsolete"? Thanks my friend

        OriginalGriffO 1 Reply Last reply
        0
        • K ksaw123

          it works but what is meant by "obsolete"? Thanks my friend

          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #4

          "Obsolete" : "No longer in use"[^] In practice, it means you should not use it for new projects; there is a better equivalent. If you do use it, be aware that future releases of the IDE may not support it, or may not support it fully. On your own head be it! Would you specify a 80386 based computer for a new project? It is obsolete too.

          All those who believe in psycho kinesis, raise my hand.

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups