MvvmCross 5.4 Crash when running an application using NullRef on ConsoleLogProvider

I updated my Xamarin.Android application package MvvmCrossfrom 5.3.2to 5.4, and when the application started, the crash started. I manually determined that the reason is the linker - I have the option enabled link SDK libs only. It Noneworks fine with the option , but makes the package twice as large.

The type initializer for 'MvvmCross.Core.Platform.LogProviders.ConsoleLogProvider' threw an exception. ---> System.NullReferenceException: the reference to the object is not installed in the object instance

+4
source share
1 answer

This is a known bug in MvvmCross 5.4 and will be fixed in a future version.

, , Setup GetDefaultLogProviderType, MvxLogProviderType.None, :

protected override MvxLogProviderType GetDefaultLogProviderType() 
    => MvxLogProviderType.None;

, IMvxLog, LinkerPleaseInclude.cs:

using System;

//[...]

public void Include(ConsoleColor color)
{
    Console.Write("");
    Console.WriteLine("");
    color = Console.ForegroundColor;
    Console.ForegroundColor = ConsoleColor.Red;
    Console.ForegroundColor = ConsoleColor.Yellow;
    Console.ForegroundColor = ConsoleColor.Magenta;
    Console.ForegroundColor = ConsoleColor.White;
    Console.ForegroundColor = ConsoleColor.Gray;
    Console.ForegroundColor = ConsoleColor.DarkGray;
}
+19

Source: https://habr.com/ru/post/1688510/


All Articles