Skip to content
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

GetAllNetworkInterfaces throws on Success on Android .NET 6 #77938

Closed
Bip901 opened this issue Nov 5, 2022 · 6 comments
Closed

GetAllNetworkInterfaces throws on Success on Android .NET 6 #77938

Bip901 opened this issue Nov 5, 2022 · 6 comments

Comments

@Bip901
Copy link

Bip901 commented Nov 5, 2022

Description

When calling System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces, instead of returning the result, a System.Net.NetworkInformation.NetworkInformationException is thrown with a message of 'Success'.

Reproduction Steps

MainActivity.cs:

namespace Test1
{
    [Activity(Label = "@string/app_name", MainLauncher = true)]
    public class MainActivity : Activity
    {
        protected override void OnCreate(Bundle? savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_main);
            var interfaces = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces();
        }
    }
}

csproj file:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net6.0-android</TargetFramework>
    <SupportedOSPlatformVersion>21</SupportedOSPlatformVersion>
    <RootNamespace>Test1</RootNamespace>
    <OutputType>Exe</OutputType>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <ApplicationId>com.example.test1</ApplicationId>
    <ApplicationVersion>1</ApplicationVersion>
    <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
  </PropertyGroup>
</Project>

Expected behavior

A list of network interfaces is returned, like on Windows.

Actual behavior

The method call throws the following exception:

System.Net.NetworkInformation.NetworkInformationException (0x80004005): Success   at System.Net.NetworkInformation.NetworkInterfacePal.TransformNetworkInterfacess[AndroidNetworkInterface[]](Func`5 transform)   at System.Net.NetworkInformation.NetworkInterfacePal.GetAndroidNetworkInterfaces()   at System.Net.NetworkInformation.NetworkInterfacePal.GetAllNetworkInterfaces()   at System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()   at LAN_Direct_Android.MainActivity.OnCreate(Bundle savedInstanceState) in D:\Ori\CSharp\LAN Direct\LAN Direct Android\MainActivity.cs:line 12   at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_(IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net6.0/android-31/mcw/Android.App.Activity.cs:line 2781   at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPL_V(_JniMarshal_PPL_V callback, IntPtr jnienv, IntPtr klazz, IntPtr p0) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 121

Regression?

Used to work in Xamarin.Android (Mono)

Known Workarounds

No response

Configuration

.NET 6 on Android x64

Other information

No response

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Nov 5, 2022
@ghost
Copy link

ghost commented Nov 5, 2022

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

When calling System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces, instead of returning the result, a System.Net.NetworkInformation.NetworkInformationException is thrown with a message of 'Success'.

Reproduction Steps

MainActivity.cs:

protected override void OnCreate(Bundle? savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); var interfaces = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces(); }

csproj file:
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net6.0-android</TargetFramework> <SupportedOSPlatformVersion>21</SupportedOSPlatformVersion> <RootNamespace>Test1</RootNamespace> <OutputType>Exe</OutputType> <Nullable>enable</Nullable> <ImplicitUsings>enable</ImplicitUsings> <ApplicationId>com.example.test1</ApplicationId> <ApplicationVersion>1</ApplicationVersion> <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion> </PropertyGroup> </Project>

Expected behavior

A list of network interfaces is returned, like on Windows.

Actual behavior

The method call throws the following exception:
System.Net.NetworkInformation.NetworkInformationException (0x80004005): Success at System.Net.NetworkInformation.NetworkInterfacePal.TransformNetworkInterfacess[AndroidNetworkInterface[]](Func5 transform) at System.Net.NetworkInformation.NetworkInterfacePal.GetAndroidNetworkInterfaces() at System.Net.NetworkInformation.NetworkInterfacePal.GetAllNetworkInterfaces() at System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces() at LAN_Direct_Android.MainActivity.OnCreate(Bundle savedInstanceState) in D:\Ori\CSharp\LAN Direct\LAN Direct Android\MainActivity.cs:line 12 at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_(IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net6.0/android-31/mcw/Android.App.Activity.cs:line 2781 at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPL_V(_JniMarshal_PPL_V callback, IntPtr jnienv, IntPtr klazz, IntPtr p0) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 121`

Regression?

Used to work in Xamarin.Android (Mono)

Known Workarounds

No response

Configuration

.NET 6 on Android x64

Other information

No response

Author: Bip901
Assignees: -
Labels:

area-System.Net

Milestone: -

@Symbai
Copy link

Symbai commented Nov 5, 2022

Sounds like a dupe of #75809 the mentioned .NET 6 backport fix is probably not live yet.

@ghost
Copy link

ghost commented Nov 7, 2022

Tagging subscribers to 'arch-android': @steveisok, @akoeplinger
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

When calling System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces, instead of returning the result, a System.Net.NetworkInformation.NetworkInformationException is thrown with a message of 'Success'.

Reproduction Steps

MainActivity.cs:

namespace Test1
{
    [Activity(Label = "@string/app_name", MainLauncher = true)]
    public class MainActivity : Activity
    {
        protected override void OnCreate(Bundle? savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_main);
            var interfaces = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces();
        }
    }
}

csproj file:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net6.0-android</TargetFramework>
    <SupportedOSPlatformVersion>21</SupportedOSPlatformVersion>
    <RootNamespace>Test1</RootNamespace>
    <OutputType>Exe</OutputType>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <ApplicationId>com.example.test1</ApplicationId>
    <ApplicationVersion>1</ApplicationVersion>
    <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
  </PropertyGroup>
</Project>

Expected behavior

A list of network interfaces is returned, like on Windows.

Actual behavior

The method call throws the following exception:

System.Net.NetworkInformation.NetworkInformationException (0x80004005): Success   at System.Net.NetworkInformation.NetworkInterfacePal.TransformNetworkInterfacess[AndroidNetworkInterface[]](Func`5 transform)   at System.Net.NetworkInformation.NetworkInterfacePal.GetAndroidNetworkInterfaces()   at System.Net.NetworkInformation.NetworkInterfacePal.GetAllNetworkInterfaces()   at System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()   at LAN_Direct_Android.MainActivity.OnCreate(Bundle savedInstanceState) in D:\Ori\CSharp\LAN Direct\LAN Direct Android\MainActivity.cs:line 12   at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_(IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net6.0/android-31/mcw/Android.App.Activity.cs:line 2781   at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPL_V(_JniMarshal_PPL_V callback, IntPtr jnienv, IntPtr klazz, IntPtr p0) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 121

Regression?

Used to work in Xamarin.Android (Mono)

Known Workarounds

No response

Configuration

.NET 6 on Android x64

Other information

No response

Author: Bip901
Assignees: -
Labels:

area-System.Net, os-android, untriaged

Milestone: -

@wfurt
Copy link
Member

wfurt commented Nov 8, 2022

cc: @simonrozsival
#75809 does not target for 6.0.

@steveisok
Copy link
Member

#77260 was the 6.0 PR. Should be in the December servicing release.

@simonrozsival
Copy link
Member

I think we can close this issue:

@marek-safar marek-safar removed the untriaged New issue has not been triaged by the area owner label Nov 9, 2022
@marek-safar marek-safar added this to the 6.0.x milestone Nov 9, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Dec 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants