Xamarin Forms.Xaml.XamlParseException

前端 未结 5 1446
长发绾君心
长发绾君心 2021-01-26 00:30

I am creating a xamarin behaviour to validate an email id, therefore I created the behaviour file and tried to localise it in XAML file but I get the below error

5条回答
  •  情深已故
    2021-01-26 01:21

    This could be related to a known linking issue - where Xamarin compiler ends up linking out classes (from external assemblies) that have references only in XAML.

    Looks like EmailBhvr might be getting linked out by the compiler. There are couple of links that talk about this:

    1. Extending Control plugins > Getting Started
    2. Force assembly linking

    There are a lot of options to resolve this:

    1. Add a static Init method in each class as mentioned here in "Getting started" section here

      // this ensures the class does not get 
      // linked out in the application we add this assembly to.
      public static void Init() { }
      
    2. Or, preserve code using preserve attributes on Android, and iOS

      public class Example
      {
           [Android.Runtime.Preserve]
           public Example ()
           {
           }
      }
      
    3. Or, use Custom linking.

    4. Or, update project configuration to not link. Android, and iOS. Not a recommended option though.

提交回复
热议问题