Bug 13461 - An exception was thrown by the type initializer for System.Net.NetworkInformation.NetworkChange ---> System.EntryPointNotFoundException: mono_sc_reachability_enabled
Summary: An exception was thrown by the type initializer for System.Net.NetworkInforma...
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 4.8.x
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2013-07-25 04:41 UTC by Luzanne
Modified: 2013-10-28 15:16 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Luzanne 2013-07-25 04:41:01 UTC
In the latest stable Xamarin.Android 4.8 version, you can't use NetworkAvailablilityChanged eventhandler. It was working in Android 4.6.x version.

Using Visual Studio 2010, on W7 64b.

I guess it is related to this bugzilla issue: https://bugzilla.xamarin.com/show_bug.cgi?id=12038

07-25 10:33:28.285 D/dalvikvm(20863): Late-enabling CheckJNI
07-25 10:33:28.301 I/dalvikvm(20863): Turning on JNI app bug workarounds for target SDK version 8...
07-25 10:33:28.348 D/dalvikvm(20863): Trying to load lib /data/app-lib/TestChangeNetwork.TestChangeNetwork-1/libmonodroid.so 0x414809b0
07-25 10:33:28.348 W/MonoDroid-Debugger(20863): Trying to initialize the debugger with options: --debugger-agent=transport=dt_socket,loglevel=0,address=127.0.0.1:8993,server=y,embedding=1
07-25 10:33:28.504 W/MonoDroid-Debugger(20863): Accepted stdout connection: 35
07-25 10:33:29.262 W/libc    (20863): WARNING: generic atexit() called from legacy shared library
07-25 10:33:29.684 W/monodroid-gc(20863): GREF GC Threshold: 46800
Loaded assembly: /data/data/TestChangeNetwork.TestChangeNetwork/files/.__override__/TestChangeNetwork.dll
Loaded assembly: Mono.Android.dll [External]
Loaded assembly: System.Core.dll [External]
Loaded assembly: MonoDroidConstructors [External]
Loaded assembly: System.dll [External]
An unhandled exception occured.
07-25 10:33:32.895 I/MonoDroid(20863): UNHANDLED EXCEPTION: System.TypeInitializationException: An exception was thrown by the type initializer for System.Net.NetworkInformation.NetworkChange ---> System.EntryPointNotFoundException: mono_sc_reachability_enabled
07-25 10:33:32.895 I/MonoDroid(20863):   at (wrapper managed-to-native) System.Net.NetworkInformation.MacNetworkChange:mono_sc_reachability_enabled ()
07-25 10:33:32.895 I/MonoDroid(20863):   at System.Net.NetworkInformation.MacNetworkChange.get_IsEnabled () [0x00000] in <filename unknown>:0 
07-25 10:33:32.895 I/MonoDroid(20863):   at System.Net.NetworkInformation.NetworkChange..cctor () [0x00000] in <filename unknown>:0 
07-25 10:33:32.895 I/MonoDroid(20863):   --- End of inner exception stack trace ---
07-25 10:33:32.895 I/MonoDroid(20863): at TestChangeNetwork.Activity1.OnCreate (Android.OS.Bundle) [0x0004b] in \\psf\home\documents\visual studio 2010\Projects\TestChangeNetwork\TestChangeNetwork\Activity1.cs:25
07-25 10:33:32.895 I/MonoDroid(20863): at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) [0x00010] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.8.0-branch/3f1c339b/source/monodroid/src/Mono.Android/platforms/android-8/src/generated/Android.App.Activity.cs:1561
07-25 10:33:32.895 I/MonoDroid(20863): at (wrapper dynamic-method) object.945b7ec4-8f42-4382-b4fe-fca5bb3daa75 (intptr,intptr,intptr) <IL 0x00017, 0x00043>
Unhandled Exception:

System.TypeInitializationException: An exception was thrown by the type initializer for System.Net.NetworkInformation.NetworkChange
07-25 10:33:33.824 E/mono    (20863): 
07-25 10:33:33.824 E/mono    (20863): Unhandled Exception:
07-25 10:33:33.824 E/mono    (20863): System.TypeInitializationException: An exception was thrown by the type initializer for System.Net.NetworkInformation.NetworkChange ---> System.EntryPointNotFoundException: mono_sc_reachability_enabled
07-25 10:33:33.824 E/mono    (20863):   at (wrapper managed-to-native) System.Net.NetworkInformation.MacNetworkChange:mono_sc_reachability_enabled ()
07-25 10:33:33.824 E/mono    (20863):   at System.Net.NetworkInformation.MacNetworkChange.get_IsEnabled () [0x00000] in <filename unknown>:0 
07-25 10:33:33.824 E/mono    (20863):   at System.Net.NetworkInformation.NetworkChange..cctor () [0x00000] in <filename unknown>:0 
07-25 10:33:33.824 E/mono    (20863):   --- End of inner exception stack trace ---
The program 'Mono' has exited with code 255 (0xff).



Steps to reproduce:

1. Create a new Android Project in Visual Studio.
2. Add the following code to the OnCreate method:

System.Net.NetworkInformation.NetworkChange.NetworkAvailabilityChanged += (s, e) =>
{
    Android.Util.Log.Debug("NetworkChange", "NetworkAvailabilityChanged called");
};

3. Run the app in debug modus.
Comment 1 Jonathan Pryor 2013-07-25 16:29:09 UTC
Fixed in monodroid/3840585c.
Comment 2 PJ 2013-07-26 17:59:53 UTC
Hi Luzanne, we're trying to assess the severity of this bug from your end. I can reproduce exactly the behavior you're describing, but we're wondering what you were doing in 4.6.8 that is failing on 4.8.0.

I had a discussion with JonP and he told me that essentially  what happened is that pre-12038, the class existed but did nothing - it was just an empty stub

12038 actually implemented it, requiring some additional glue which is what caused this bug: the glue was missing in XA, hence the exception

So the end result is that after 3840585c it works in that it doesn't throw an exception, but it doesn't actually do anything.

We'll get this fixed for the next non-hotfix release, but I wanted to let you know why exactly it wasn't hotfixed on our end and perhaps help you get around the particular blocking issue you're experiencing.
Comment 3 Luzanne 2013-07-26 19:26:57 UTC
The eventhandler was never implemented in an earlier version of MonoDroid? And in MonoTouch? It is shared code between Android and iOS, in a project i'm working on.

In MonoTouch we are experiencing the same issue (a crash) with the latest stable version.

It is not really a blocking issue, i commented out the line so it doesn't get called anymore. I have to search for another way to get the network changes.
Comment 4 pagghiu 2013-10-28 07:33:10 UTC
This error also happens with any regular windows console exe that has been mkbundled on windows (Mono 3.2.3).
Comment 5 Jonathan Pryor 2013-10-28 15:16:40 UTC
@pagghui: A mkbundled app will need to include libMonoPosixHelper.dll, which contains the missing mono_sc_reachability_enabled() function.

This is also somewhat moot, as mono/d0756232 changed everything, such that mono_sc_reachability_enabled() is no longer required.