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
For the import to work, the class EmailBhvr must
Be especially careful with 2.: If you use a shared Project the assembly name will be that of the platform project (e.g. it could be Validation.Droid / Validation.iOS). That can be fixed be giving both the same Assembly name (in project properties). For example "Validation.Platform" and change the xaml namespace import accordingly
I think you made some mistake while writing tags/property names in your EmailBhvr file.
Because of that you are getting parsing exception.
Please Make sure that the assembly name in XAML is correct. it should be like this xmlns:local="clr-namespace:ProjectNamspace.Validation;assembly=ProjectNamspace.Validation"
I feel your XAML is clean. Looks error free. I think the problem is with the EmailBhvr
class in Validation
. I suggest you to verify it. Make sure that the assembly name in XAML is also correct. XamlParseException can also occur with the incorrect assembly name..
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:
There are a lot of options to resolve this:
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() { }
Or, preserve code using preserve attributes on Android, and iOS
public class Example
{
[Android.Runtime.Preserve]
public Example ()
{
}
}
Or, use Custom linking.
Or, update project configuration to not link. Android, and iOS. Not a recommended option though.