Android application crashes on release while using a String value inside a ResourceDictionary.xaml file. The same does not happen when testing in Debug (with the String resources) or when testing in Release without the String resources.
Strings.xaml file, without any bundled .cs file.<ResourceDictionary xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:s="clr-namespace:System;assembly=netstandard">
<s:String x:Key="S.SignUp">Sign Up</s:String>
<s:String x:Key="S.SignIn">Sign In</s:String>
</ResourceDictionary>
<ResourceDictionary Source="Resources/Strings.xaml"/>
Application should not crash with the String resources.
Application crash on splashscreen on release mode with this error message, captured by DeviceMonitor:
android.runtime.JavaProxyThrowable:
Xamarin.Forms.Xaml.XamlParseException: Position 10:6. Type s:String not found in xmlns clr-namespace:System;assembly=netstandard
at Xamarin.Forms.Xaml.CreateValuesVisitor.Visit (Xamarin.Forms.Xaml.ElementNode node, Xamarin.Forms.Xaml.INode parentNode)
at Xamarin.Forms.Xaml.ElementNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode)
at Xamarin.Forms.Xaml.RootNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode)
at Xamarin.Forms.Xaml.XamlLoader.Visit (Xamarin.Forms.Xaml.RootNode rootnode, Xamarin.Forms.Xaml.HydrationContext visitorContext, System.Boolean useDesignProperties)
at Xamarin.Forms.Xaml.XamlLoader.Load (System.Object view, System.String xaml, System.Boolean useDesignProperties)
at Xamarin.Forms.Xaml.XamlLoader.Load (System.Object view, System.String xaml)
at Xamarin.Forms.Xaml.Extensions.LoadFromXaml[TXaml] (TXaml view, System.String xaml)
at Xamarin.Forms.Xaml.ResourcesLoader.CreateFromResource[T] (System.String resourcePath, System.Reflection.Assembly assembly, System.Xml.IXmlLineInfo lineInfo)
at Xamarin.Forms.ResourceDictionary.SetAndLoadSource (System.Uri value, System.String resourcePath, System.Reflection.Assembly assembly, System.Xml.IXmlLineInfo lineInfo)
at ... App initialization code, Activity initialization code.
I tried to add a xml file with the build action called "LinkDescription" the same way as I did with the crash on release caused by EntityFramework, with no luck.
Like this:
<?xml version="1.0" encoding="UTF-8" ?>
<linker>
<assembly fullname="mscorlib">
<type fullname="System.DateTime" preserve="methods"/>
<type fullname="System.String" preserve="methods"/>
</assembly>
</linker>
And like this:
<?xml version="1.0" encoding="UTF-8" ?>
<linker>
<assembly fullname="mscorlib">
<type fullname="System.DateTime" preserve="methods"/>
</assembly>
<assembly fullname="netstandard">
<type fullname="System.String" preserve="methods"/>
</assembly>
</linker>
Same issue as this forum thread.
Use <x:String> instead.
@jcmanke That's right, it's working now after using <x:String>.
I only used String from NetStandard because that's what was suggested by VS/Resharper.
Should I close this issue ticket?
Thanks everyone! :)