Xamarin为Mac clean-namespace问题构建了visual studio

问题描述 投票:0回答:2

我使用.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
2个回答
0
投票

实际上这个问题很常见,你的项目编译不正确或者在编译bin之后,obj都缺少这个类,这很好。

解:

  • 从解决方案中的所有项目中删除所有bin obj文件夹。
  • 现在根据依赖性单独构建所有项目,即如果你有四个项目A,B,iOS和Android,B依赖于A,即它有一个A的引用,那么你将首先清理构建A然后B,然后在iOS和Android系统。
  • 如果即使在此之后您的问题仍未解决,那么您可能希望一起重启VS.

如果您仍然面临此问题,请随时恢复。

祝好运


0
投票

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

我在assembly属性中输入“:”而不是“=”。

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

© www.soinside.com 2019 - 2024. All rights reserved.