e/5 :clock5:help wantedinactivet/bug :bug:up-for-grabs
仓库指标
- 星标
- (5,644 个星标)
- PR 合并指标
- (30 天内没有已合并 PR)
描述
When linking is set to SDK only I get the following runtime exception on both Android and iOS.
{Xamarin.Forms.Xaml.XamlParseException: Position 13:6. Type system:Boolean 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) [0x0005f] in D:\a\1\s\Xamarin.Forms.Xaml\CreateValuesVisitor.cs:53
at Xamarin.Forms.Xaml.ElementNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) [0x000ac] in D:\a\1\s\Xamarin.Forms.Xaml\XamlNode.cs:149
at Xamarin.Forms.Xaml.RootNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) [0x00079] in D:\a\1\s\Xamarin.Forms.Xaml\XamlNode.cs:202
at Xamarin.Forms.Xaml.XamlLoader.Visit (Xamarin.Forms.Xaml.RootNode rootnode, Xamarin.Forms.Xaml.HydrationContext visitorContext, System.Boolean useDesignProperties) [0x00064] in D:\a\1\s\Xamarin.Forms.Xaml\XamlLoader.cs:148
at Xamarin.Forms.Xaml.XamlLoader.Load (System.Object view, System.String xaml, System.Boolean useDesignProperties) [0x00058] in D:\a\1\s\Xamarin.Forms.Xaml\XamlLoader.cs:91
at Xamarin.Forms.Xaml.XamlLoader.Load (System.Object view, System.String xaml) [0x00000] in D:\a\1\s\Xamarin.Forms.Xaml\XamlLoader.cs:72
at Xamarin.Forms.Xaml.Extensions.LoadFromXaml[TXaml] (TXaml view, System.String xaml) [0x00000] in <24d2c2bdb410419cb183b7f649f813d4>:0
at Xamarin.Forms.Xaml.ResourcesLoader.CreateFromResource[T] (System.String resourcePath, System.Reflection.Assembly assembly, System.Xml.IXmlLineInfo lineInfo) [0x000ad] in <24d2c2bdb410419cb183b7f649f813d4>:0
at Xamarin.Forms.ResourceDictionary.SetAndLoadSource (System.Uri value, System.String resourcePath, System.Reflection.Assembly assembly, System.Xml.IXmlLineInfo lineInfo) [0x00063] in D:\a\1\s\Xamarin.Forms.Core\ResourceDictionary.cs:72
at MyProject.App.InitializeComponent () [0x00012] in C:\Users\usr\source\repos\MyProject\MyProject\MyProject\obj\Debug\netstandard2.0\App.xaml.g.cs:22
at MyProject.App..ctor () [0x0004d] in C:\Users\usr\source\repos\MyProject\MyProject\MyProject\App.xaml.cs:52
at MyProject.iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication app, Foundation.NSDictionary options) [0x000eb] in C:\Users\usr\source\repos\MyProject\MyProject\MyProject.iOS\AppDelegate.cs:69
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 /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.0/src/Xamarin.iOS/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0002c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.0/src/Xamarin.iOS/UIKit/UIApplication.cs:63
at MyProject.iOS.Application.Main (System.String[] args) [0x00002] in C:\Users\usr\source\repos\MyProject\MyProject\MyProject.iOS\Main.cs:11 }
This happens for resources such as system:Boolean, system:Int32
<ResourceDictionary xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:system="clr-namespace:System;assembly=netstandard">
<x:Double x:Key="MyDouble">20</x:Double>
<system:Boolean x:Key="MyBool">True</system:Boolean>
</ResourceDictionary>
In this snippet, the parser will throw when it encounters the MyBool.
Some people suggested using a type in the code will be enough to stop the linker, but this does not seem to be the case. I have also found tips on how to preserve types I declare myself and how to tell the linker to skip a namespace, but neither applies here in my opinion.
I would also mention the dictionary does not have a code-behind file and is merged to the app resources.
What is the best approach?