@@ -242,7 +242,9 @@ static void ManualJavaObjectDispose (Java.Lang.Object obj)
242
242
}
243
243
244
244
static Action < Exception > mono_unhandled_exception = null ! ;
245
+ #if ! NETCOREAPP
245
246
static Action < AppDomain , UnhandledExceptionEventArgs > AppDomain_DoUnhandledException = null ! ;
247
+ #endif
246
248
247
249
static void Initialize ( )
248
250
{
@@ -253,6 +255,7 @@ static void Initialize ()
253
255
mono_unhandled_exception = ( Action < Exception > ) Delegate . CreateDelegate ( typeof ( Action < Exception > ) , mono_UnhandledException ) ;
254
256
}
255
257
258
+ #if ! NETCOREAPP
256
259
if ( AppDomain_DoUnhandledException == null ) {
257
260
var ad_due = typeof ( AppDomain )
258
261
. GetMethod ( "DoUnhandledException" ,
@@ -265,8 +268,14 @@ static void Initialize ()
265
268
typeof ( Action < AppDomain , UnhandledExceptionEventArgs > ) , ad_due ) ;
266
269
}
267
270
}
271
+ #endif
268
272
}
269
273
274
+ #if NETCOREAPP
275
+ [ DllImport ( AndroidRuntime . InternalDllName , CallingConvention = CallingConvention . Cdecl ) ]
276
+ extern static void monodroid_unhandled_exception ( Exception javaException ) ;
277
+ #endif
278
+
270
279
internal static void PropagateUncaughtException ( IntPtr env , IntPtr javaThreadPtr , IntPtr javaExceptionPtr )
271
280
{
272
281
if ( ! PropagateExceptions )
@@ -287,14 +296,18 @@ internal static void PropagateUncaughtException (IntPtr env, IntPtr javaThreadPt
287
296
try {
288
297
var jltp = javaException as JavaProxyThrowable ;
289
298
Exception ? innerException = jltp ? . InnerException ;
290
- var args = new UnhandledExceptionEventArgs ( innerException ?? javaException , isTerminating : true ) ;
291
299
292
300
Logger . Log ( LogLevel . Info , "MonoDroid" , "UNHANDLED EXCEPTION:" ) ;
293
301
Logger . Log ( LogLevel . Info , "MonoDroid" , javaException . ToString ( ) ) ;
294
302
303
+ #if ! NETCOREAPP
304
+ var args = new UnhandledExceptionEventArgs ( innerException ?? javaException , isTerminating : true ) ;
295
305
// Disabled until Linker error surfaced in https://github.com/xamarin/xamarin-android/pull/4302#issuecomment-596400025 is resolved
296
306
//AppDomain.CurrentDomain.DoUnhandledException (args);
297
307
AppDomain_DoUnhandledException ? . Invoke ( AppDomain . CurrentDomain , args ) ;
308
+ #else
309
+ monodroid_unhandled_exception ( innerException ?? javaException ) ;
310
+ #endif
298
311
} catch ( Exception e ) {
299
312
Logger . Log ( LogLevel . Error , "monodroid" , "Exception thrown while raising AppDomain.UnhandledException event: " + e . ToString ( ) ) ;
300
313
}
0 commit comments