Skip to content

GetIsNetworkAvailable() behaves differently depending on .NET version #125167

@liangming2003

Description

@liangming2003

Description

We have a project using following function call:

var isNetworkAvailable = NetworkInterface.GetIsNetworkAvailable();

On a Win11 LTSC (W11 IoT Enterprise LTSC) test unit with no network connection (Ethernet cable unplugged and Wi-Fi not connected).

When the project is built with .NET 8.0, the function GetIsNetworkAvailable() returns false.
When the project is built with .NET 9.0, the function GetIsNetworkAvailable() returns true.

Here is Microsoft support's explanation on why GetIsNetworkAvailable() behaves differently depending on .NET version:
https://learn.microsoft.com/en-gb/answers/questions/5763874/getisnetworkavailable()-behaves-differently-depend

We like to keep the function behavior of .NET 8.0 when building the project with .NET 9.0. Is there any equivalent code to replace the function GetIsNetworkAvailable()? Or, This is a bug that will be fixed in a later version. Thanks.

Reproduction Steps

var isNetworkAvailable = NetworkInterface.GetIsNetworkAvailable();

On a Win11 LTSC (W11 IoT Enterprise LTSC) test unit with no network connection (Ethernet cable unplugged and Wi-Fi not connected).

When the project is built with .NET 8.0, the function GetIsNetworkAvailable() returns false.
When the project is built with .NET 9.0, the function GetIsNetworkAvailable() returns true.

Expected behavior

On a Win11 LTSC (W11 IoT Enterprise LTSC) test unit with no network connection (Ethernet cable unplugged and Wi-Fi not connected).

When the project is built with .NET 9.0, the function GetIsNetworkAvailable() returns false.

Actual behavior

On a Win11 LTSC (W11 IoT Enterprise LTSC) test unit with no network connection (Ethernet cable unplugged and Wi-Fi not connected).

When the project is built with .NET 9.0, the function GetIsNetworkAvailable() returns true.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions