Xamarin Forms.Xaml.XamlParseException [英] Xamarin Forms.Xaml.XamlParseException

查看:73
本文介绍了Xamarin Forms.Xaml.XamlParseException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个xamarin行为来验证电子邮件ID,因此我创建了行为文件并尝试将其本地化为XAML文件,但出现以下错误

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

Xamarin.Forms.Xaml.XamlParseException:位置12:10.类型 在xmlns中找不到local:EmailBhvr clr-namespace:Validation.Helpers; assembly = Validation.Helpers

Xamarin.Forms.Xaml.XamlParseException: Position 12:10. Type local:EmailBhvr not found in xmlns clr-namespace:Validation.Helpers;assembly=Validation.Helpers

命名空间:验证

行为代码文件:EmailBhvr

Behaviour Code File: EmailBhvr

这是我的XAML代码:

Here is my XAML code:

<? xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns = "http://xamarin.com/schemas/2014/forms"
                xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                xmlns:local="clr-namespace:Validation;assembly=Validation"
                x:Class="Validation.WelcomePage">
    <StackLayout>
    <Label Text = "Hello Xamarin" />


    < Entry Placeholder="Enter your full name" x:Name="myName">
        <Entry.Behaviors>
        <local:EmailBhvr />
        </Entry.Behaviors>
    </Entry>

    <Entry Placeholder = "Enter your email" x:Name="myEmail" />

    <Entry Placeholder = "Enter password" x:Name="myPassword" IsPassword="True"  />

    <Entry Placeholder = "Confirm password" x:Name="myConfirmPassword" IsPassword="True"  />

    <Button Text = "Save" x:Name="SaveRegistration"/>
    </StackLayout>
</ContentPage>

推荐答案

这可能与一个已知的链接问题有关-Xamarin编译器最终链接了仅在XAML中具有引用的类(从外部程序集).

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.

看起来像EmailBhvr可能已被编译器链接出去.有几个有关此的链接:

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

  1. 扩展控件插件>入门
  2. 强制程序集链接
  1. Extending Control plugins > Getting Started
  2. Force assembly linking

有很多选项可以解决此问题:

There are a lot of options to resolve this:

  1. 在每个类中,如入门"部分所述

  2. 或者,使用 Android 上的保存属性来保存代码 iOS

  3. Or, preserve code using preserve attributes on Android, and iOS

    public class Example
    {
         [Android.Runtime.Preserve]
         public Example ()
         {
         }
    }
    

  4. 或者使用自定义链接.

    或者,将项目配置更新为不链接. Android

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

    这篇关于Xamarin Forms.Xaml.XamlParseException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆