Skip to content
This repository was archived by the owner on Sep 13, 2022. It is now read-only.

Cannot use Dns.GetHostAddresses from .NET Standard 1.6 Library #1431

Closed
watfordgnf opened this issue Aug 12, 2019 · 1 comment
Closed

Cannot use Dns.GetHostAddresses from .NET Standard 1.6 Library #1431

watfordgnf opened this issue Aug 12, 2019 · 1 comment

Comments

@watfordgnf
Copy link

watfordgnf commented Aug 12, 2019

Working on a fix for NATS, I used Dns.GetHostAddresses from the main library. The library is being built against .NET Standard 1.6.1, and I added the System.Net.NameResolution NuGet package to get this API. When trying to use it I receive the following build error:

1>Conn.cs(435,53,435,69): error CS0117: 'Dns' does not contain a definition for 'GetHostAddresses'

IntelliSense only suggests Dns.GetHostAddressesAsync.

I'm not sure why I can't use Dns.GetHostAddresses. Reviewing the .NET Standard 1.6 API it is clear it wasn't shipped, so I added the relevant NuGet package. The NuGet package states it supports at least .NET Standard 1.3. Looking at the code in question, I cannot find any evidence it excludes that method for .NET Standard.

@terrajobst
Copy link

The API definition for earlier versions of .NET Standard are fixed. In .NET Standard 1.3, the API surface of Dns was limited to this:

public static class Dns
{
	public static Task<IPAddress[]> GetHostAddressesAsync(string hostNameOrAddress);
	public static Task<IPHostEntry> GetHostEntryAsync(IPAddress address);
	public static Task<IPHostEntry> GetHostEntryAsync(string hostNameOrAddress);
	public static string GetHostName();
}

The rest came back in .NET Standard 2.0, which includes the Dns.GetHostAddresses method.

@terrajobst terrajobst added this to the .NET Standard 2.0 milestone Aug 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants