【问题标题】:Xamarin forms visual studio for Mac clean-namespace problemXamarin 为 Mac 干净命名空间问题形成 Visual Studio
【发布时间】:2019-08-02 13:00:11
【问题描述】:

我使用 .net 标准创建了一个 Xamarin 表单应用程序。然后,我在解决方案中添加了一个 .net 标准库项目,其中将包括常见代码,例如渲染、行为等。我通过右键单击依赖项和编辑引用菜单,将通用 .net 标准库项目的引用包含到主 Xamarin 表单项目中.最后,我尝试通过指定以下行在主要 Xamarin 表单的内容页面上包含渲染器文件的命名空间 使用 Xamarin.Forms;

namespace MyProject.Shared.Renderer
{
    public class ExtendedEntry : Entry
    {
        public static readonly BindableProperty IsBorderErrorVisibleProperty = BindableProperty.Create(nameof(IsBorderErrorVisible), typeof(bool), typeof(ExtendedEntry),
            false, BindingMode.TwoWay);

        public bool IsBorderErrorVisible
        {
            get { return (bool)GetValue(IsBorderErrorVisibleProperty); }
            set { SetValue(IsBorderErrorVisibleProperty, value); }
        }

        public static readonly BindableProperty BorderErrorColorProperty = BindableProperty.Create(nameof(BorderErrorColor), typeof(Color), typeof(ExtendedEntry),
            null, BindingMode.TwoWay);

        public Color BorderErrorColor
        {
            get { return (Color)GetValue(BorderErrorColorProperty); }
            set { SetValue(BorderErrorColorProperty, value); }
        }

        public static readonly BindableProperty ErrorTextProperty = BindableProperty.Create(nameof(ErrorText), typeof(string), typeof(ExtendedEntry), string.Empty,
            BindingMode.TwoWay);

        public string ErrorText
        {
            get { return (string)GetValue(ErrorTextProperty); }
            set { SetValue(ErrorTextProperty, value); }
        }
    }
}
xmlns:controls=“clr-namespace:MyProject.Shared.Renderer:assembly:MyProject.Shared”

Then I reference the control as
<controls:ExtendedEntry />

但这会产生生成错误,提示在程序集 MyProject.Shared 中找不到 ExtendedEntry

请帮忙

【问题讨论】:

    标签: xamarin.forms xamarin.android xamarin.ios xamarin-studio .net-standard


    【解决方案1】:

    其实这个问题是很常见的

    解决方案:

    • 从解决方案中的所有项目中删除所有 bin obj 文件夹。

    • 现在根据依赖关系单独构建所有项目,即如果您有四个项目 A、B、iOS 和 Android,并且 B 依赖于 A,即它具有对 A 的引用,那么您将首先清理构建 A,然后构建 B然后是 iOS 和 Android 中的任何一个。

    • 如果即使在此之后您的问题仍未解决,那么您可能需要一起重新启动 VS

    如果您仍然遇到此问题,请随时回复。

    祝你好运

    【讨论】:

    • 我会在实施您的解决方案后通知您。非常感谢
    • 当然没问题
    • 能否添加整个页面的代码进行扩展输入?
    • 请添加代码。我正在使用 Visual Studio for MAC 而不是 vs2017
    • @TishaAnand 我知道你正在使用 Visual Studio for mac!
    【解决方案2】:

    对不起...我犯了一个错误...一个真正的错误。

    我在程序集属性中输入了“:”而不是“=”。

    应该是 xmlns:controls=“clr-namespace:MyProject.Shared.Renderer:assembly=MyProject.Shared”

    【讨论】:

    • 很高兴您找到了解决方案
    猜你喜欢
    • 2010-11-14
    • 1970-01-01
    • 1970-01-01
    • 2013-10-23
    • 2023-03-03
    • 1970-01-01
    • 1970-01-01
    • 2010-12-27
    • 1970-01-01
    相关资源
    最近更新 更多