From 1f7e703e670bbd992b56968f38cb73195f6575bc Mon Sep 17 00:00:00 2001 From: Alan McGovern Date: Thu, 16 Feb 2017 23:55:56 +0000 Subject: [PATCH 1/2] [XM] Add the option to ignore missing files during registration Not all assemblies referenced at compile time are necessary at runtime. Allow XamMac to ignore missing assemblies just like iOS does. Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=51746 --- src/AppKit/NSApplication.cs | 1 + src/ObjCRuntime/Runtime.cs | 9 ++++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/AppKit/NSApplication.cs b/src/AppKit/NSApplication.cs index 2eada1d5da8b..1900dc209506 100644 --- a/src/AppKit/NSApplication.cs +++ b/src/AppKit/NSApplication.cs @@ -33,6 +33,7 @@ namespace XamCore.AppKit { public partial class NSApplication : NSResponder { public static bool CheckForIllegalCrossThreadCalls = true; public static bool CheckForEventAndDelegateMismatches = true; + public static bool IgnoreMissingAssembliesDuringRegistration = false; private static Thread mainThread; diff --git a/src/ObjCRuntime/Runtime.cs b/src/ObjCRuntime/Runtime.cs index a03a0d11f4e3..d1143a8fab1a 100644 --- a/src/ObjCRuntime/Runtime.cs +++ b/src/ObjCRuntime/Runtime.cs @@ -408,14 +408,13 @@ static void CollectReferencedAssemblies (List assemblies, Assembly ass if (!assemblies.Contains (a)) CollectReferencedAssemblies (assemblies, a); } -#if MONOMAC - catch { + catch (FileNotFoundException fefe) { // that's more important for XI because device builds don't go thru this step // and we can end up with simulator-only failures - bug #29211 - throw; -#else - catch (FileNotFoundException fefe) { NSLog ("Could not find `{0}` referenced by assembly `{1}`.", fefe.FileName, assembly.FullName); +#if MONOMAC + if (!NSApplication.IgnoreMissingAssembliesDuringRegistration) + throw; #endif } } From 27b00800ccfcdbe405820025cd63195405e90b5b Mon Sep 17 00:00:00 2001 From: Chris Hamons Date: Tue, 21 Feb 2017 13:02:43 -0600 Subject: [PATCH 2/2] Fix build --- src/ObjCRuntime/Runtime.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ObjCRuntime/Runtime.cs b/src/ObjCRuntime/Runtime.cs index d1143a8fab1a..f78f4e6e52a6 100644 --- a/src/ObjCRuntime/Runtime.cs +++ b/src/ObjCRuntime/Runtime.cs @@ -17,6 +17,10 @@ using XamCore.Foundation; using XamCore.Registrar; +#if MONOMAC +using XamCore.AppKit; +#endif + #if !COREBUILD && (XAMARIN_APPLETLS || XAMARIN_NO_TLS) #if !MMP && !MTOUCH && !MTOUCH_TEST using Mono.Security.Interface;