Skip to content

IPInterfaceProperties.GetIPv(4|6)Properties never returns null #11056

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

Check failure on line 1 in snippets/cpp/VS_Snippets_Remoting/NCLNetInfo2/CPP/networkexamples.cpp

View workflow job for this annotation

GitHub Actions / snippets-build

ERROR: Project missing. A project (and optionally a solution file) must be in this directory or one of the parent directories to validate and build this code.

#using <System.dll>

Expand Down Expand Up @@ -836,11 +836,6 @@

// Try to get the IPv4 interface properties.
IPv4InterfaceProperties ^ p = adapterProperties->GetIPv4Properties();
if ( !p )
{
Console::WriteLine( "No IPv4 information is available for this interface." );
continue;
}

// Display the IPv4 specific data.
Console::WriteLine( " Index ............................. : {0}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -796,12 +796,6 @@ public static void DisplayIPv4NetworkInterfaces()
// Try to get the IPv4 interface properties.
IPv4InterfaceProperties p = adapterProperties.GetIPv4Properties();

if (p == null)
{
Console.WriteLine("No IPv4 information is available for this interface.");
Console.WriteLine();
continue;
}
// Display the IPv4 specific data.
Console.WriteLine(" Index ............................. : {0}", p.Index);
Console.WriteLine(" MTU ............................... : {0}", p.Mtu);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@


Check failure on line 1 in snippets/visualbasic/VS_Snippets_Remoting/NCLNetInfo2/VB/networkexamples.vb

View workflow job for this annotation

GitHub Actions / snippets-build

ERROR: Project missing. A project (and optionally a solution file) must be in this directory or one of the parent directories to validate and build this code.
Imports System.Net
Imports System.Net.NetworkInformation
Imports System.Net.Sockets
Expand Down Expand Up @@ -695,11 +695,7 @@
Dim adapterProperties As IPInterfaceProperties = adapter.GetIPProperties()
' Try to get the IPv4 interface properties.
Dim p As IPv4InterfaceProperties = adapterProperties.GetIPv4Properties()

If p Is Nothing Then
Console.WriteLine("No IPv4 information is available for this interface.")
GoTo ContinueForEach1
End If

' Display the IPv4 specific data.
Console.WriteLine(" Index ............................. : {0}", p.Index)
Console.WriteLine(" MTU ............................... : {0}", p.Mtu)
Expand Down
6 changes: 4 additions & 2 deletions xml/System.Net.NetworkInformation/IPInterfaceProperties.xml
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,8 @@

## Remarks
For a detailed description of the information available for an interface that supports IPv4, see the <xref:System.Net.NetworkInformation.IPv4InterfaceProperties> class documentation. Note that the object returned by the <xref:System.Net.NetworkInformation.IPInterfaceProperties.GetIPv4Properties%2A> method reflects the configuration as of the time the object is created. This information is not updated dynamically.

A <xref:System.Net.NetworkInformation.NetworkInformationException> is thrown if the interface does not support the IPv4 protocol, therefore it's recommended to check IPv4 support calling <xref:System.Net.NetworkInformation.NetworkInterface.Supports%2A> on the originating <xref:System.Net.NetworkInformation.NetworkInterface> instance before querying the IPv4 properties.

]]></format>
</remarks>
<exception cref="T:System.Net.NetworkInformation.NetworkInformationException">The interface does not support the IPv4 protocol.</exception>
Expand Down Expand Up @@ -544,7 +545,8 @@

## Remarks
For a detailed description of the information available for an interface that supports IPv6, see the <xref:System.Net.NetworkInformation.IPv6InterfaceProperties> documentation. Note that the object returned by the <xref:System.Net.NetworkInformation.IPInterfaceProperties.GetIPv6Properties%2A> method reflects the configuration as of the time the object is created. This information is not updated dynamically.

A <xref:System.Net.NetworkInformation.NetworkInformationException> is thrown if the interface does not support the IPv6 protocol, therefore it's recommended to check IPv6 support calling <xref:System.Net.NetworkInformation.NetworkInterface.Supports%2A> on the originating <xref:System.Net.NetworkInformation.NetworkInterface> instance before querying the IPv6 properties.

]]></format>
</remarks>
<exception cref="T:System.Net.NetworkInformation.NetworkInformationException">The interface does not support the IPv6 protocol.</exception>
Expand Down
Loading