Updated application to MvvmCross 5.4.0 and the new IMvxLog and IMvxLogProvider logging system
Tested on iOS simulator without issues
Running on physical iPhone 8, iOS 11.0.3 device throws exception at:
var setup = new Setup(this, Window);
setup.Initialize();
Should not crash, as I haven't added any custom IMvxLogProvider providers, and done any change (other than injecting IMvxLogProvider and IMvxLog in my classes instead of using Mvx.TaggedTrace). So this could be a problem for more users upgrading from MvvmCross 5.3.
This is the exception thrown at runtime:
Unhandled Exception:
System.TypeInitializationException: The type initializer for 'MvvmCross.Core.Platform.LogProviders.ConsoleLogProvider' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object
at MvvmCross.Core.Platform.LogProviders.TypeExtensions.GetGetMethod (System.Reflection.PropertyInfo propertyInfo) [0x00000] in <68c6fe7539fa471eb0fb4e1ad2630d0d>:0
at MvvmCross.Core.Platform.LogProviders.ConsoleLogProvider.GetGetConsoleForeground () [0x0000f] in <68c6fe7539fa471eb0fb4e1ad2630d0d>:0
at MvvmCross.Core.Platform.LogProviders.ConsoleLogProvider..cctor () [0x0009e] in <68c6fe7539fa471eb0fb4e1ad2630d0d>:0
--- End of inner exception stack trace ---
at (wrapper managed-to-native) System.Object:__icall_wrapper_mono_generic_class_init (intptr)
at MvvmCross.Core.Platform.MvxSetup.CreateLogProvider () [0x00029] in <68c6fe7539fa471eb0fb4e1ad2630d0d>:0
at MvvmCross.Core.Platform.MvxSetup.InitializeDebugServices () [0x00012] in <68c6fe7539fa471eb0fb4e1ad2630d0d>:0
at MvvmCross.Core.Platform.MvxSetup.InitializePrimary () [0x000a0] in <68c6fe7539fa471eb0fb4e1ad2630d0d>:0
at MvvmCross.Core.Platform.MvxSetup.Initialize () [0x00000] in <68c6fe7539fa471eb0fb4e1ad2630d0d>:0
at Blueye.App.iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication application, Foundation.NSDictionary launchOptions) [0x0002f] in /Users/follesoe/Source/BlueyeApp/iOS/AppDelegate.cs:40
at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/5481/12e80e01/source/xamarin-macios/src/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/5481/12e80e01/source/xamarin-macios/src/UIKit/UIApplication.cs:63
at Blueye.App.iOS.Application.Main (System.String[] args) [0x00001] in /Users/follesoe/Source/BlueyeApp/iOS/Main.cs:17
2017-11-02 16:52:18.681 Blueye.App.iOS[5554:1805918] Unhandled managed exception:
The type initializer for 'MvvmCross.Core.Platform.LogProviders.ConsoleLogProvider' threw an exception. (System.TypeInitializationException)
at (wrapper managed-to-native) System.Object:__icall_wrapper_mono_generic_class_init (intptr)
at MvvmCross.Core.Platform.MvxSetup.CreateLogProvider () [0x00029] in <68c6fe7539fa471eb0fb4e1ad2630d0d>:0
at MvvmCross.Core.Platform.MvxSetup.InitializeDebugServices () [0x00012] in <68c6fe7539fa471eb0fb4e1ad2630d0d>:0
at MvvmCross.Core.Platform.MvxSetup.InitializePrimary () [0x000a0] in <68c6fe7539fa471eb0fb4e1ad2630d0d>:0
at MvvmCross.Core.Platform.MvxSetup.Initialize () [0x00000] in <68c6fe7539fa471eb0fb4e1ad2630d0d>:0
at Blueye.App.iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication application, Foundation.NSDictionary launchOptions) [0x0002f] in /Users/follesoe/Source/BlueyeApp/iOS/AppDelegate.cs:40
at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/5481/12e80e01/source/xamarin-macios/src/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/5481/12e80e01/source/xamarin-macios/src/UIKit/UIApplication.cs:63
at Blueye.App.iOS.Application.Main (System.String[] args) [0x00001] in /Users/follesoe/Source/BlueyeApp/iOS/Main.cs:17
--- inner exception ---
Object reference not set to an instance of an object (System.NullReferenceException)
at MvvmCross.Core.Platform.LogProviders.TypeExtensions.GetGetMethod (System.Reflection.PropertyInfo propertyInfo) [0x00000] in <68c6fe7539fa471eb0fb4e1ad2630d0d>:0
at MvvmCross.Core.Platform.LogProviders.ConsoleLogProvider.GetGetConsoleForeground () [0x0000f] in <68c6fe7539fa471eb0fb4e1ad2630d0d>:0
at MvvmCross.Core.Platform.LogProviders.ConsoleLogProvider..cctor () [0x0009e] in <68c6fe7539fa471eb0fb4e1ad2630d0d>:0
2017-11-02 16:52:18.681 Blueye.App.iOS[5554:1805918] critical: Stacktrace:
It looks like the problem is this line: https://github.com/MvvmCross/MvvmCross/blob/00def71adfc391bf0e6b9a477329227409717983/MvvmCross/Core/Core/Platform/LogProviders/ConsoleLogProvider.cs#L96
MethodInfo getForeground = ConsoleType.GetPropertyPortable("ForegroundColor").GetGetMethod();
The GetPropertyPortable returns null, so need check before GetGetMethod call?
Version: 5.4.0
Platform:
See that this is a known bug that will be fixed in 5.4.1: https://stackoverflow.com/questions/47050608/mvvmcross-5-4-crash-on-app-startup-with-nullref-at-consolelogprovider/47052169#47052169
Yes, you can already include this locally in your LinkerPleaseInclude and it will work.
Most helpful comment
See that this is a known bug that will be fixed in 5.4.1: https://stackoverflow.com/questions/47050608/mvvmcross-5-4-crash-on-app-startup-with-nullref-at-consolelogprovider/47052169#47052169