xamarin.forms - Xamarin 为 Mac 干净命名空间问题形成 Visual Studio
问题描述
我使用 .net 标准创建了一个 Xamarin 表单应用程序。然后,我在解决方案中添加了一个 .net 标准库项目,其中将包括常见代码,例如渲染、行为等。我通过右键单击依赖项和 Edit References 菜单,将通用 .net 标准库项目的引用包含到主 Xamarin 表单项目中. 最后,我尝试通过使用 Xamarin.Forms 指定以下行,在主要 Xamarin 表单的内容页面上包含渲染器文件的命名空间;
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
请帮忙
解决方案
好吧,实际上这个问题很常见,因为您的项目没有正确编译,或者在编译 bin 和 obj 之后缺少这个类,这很好。
解决方案:
从解决方案中的所有项目中删除所有 bin obj 文件夹。
现在根据依赖关系单独构建所有项目,即如果您有四个项目 A、B、iOS 和 Android 并且 B 依赖于 A 即它具有对 A 的引用,那么您将首先清理构建 A 然后 B 然后在 iOS 和安卓。
如果即使在此之后您的问题仍未解决,那么您可能希望一起重新启动 VS
如果您仍然遇到此问题,请随时恢复。
祝你好运
推荐阅读
- c++ - vulkan-hpp 中奇怪的 C++ 语法
- javascript - 外部javascript可以在网站上访问什么。出于安全原因询问
- http - IdHttp 返回 HTTP 1.1/ 403 Forbidden。HttpClient 工作正常
- c# - Windows MSI 安装程序:依赖解析不起作用,安装了错误的程序集
- java - 一段时间后,Coldfusion 停止使用 smtp.gmail.com 发送电子邮件
- c# - System.ArgumentNullException: '值不能为空。参数名称:items'
- vue.js - 如果出现身份验证问题,如何通过查询重复操作?
- django - 在覆盖默认“创建”方法时尝试保存数据时出现不清楚的错误
- sql - 如果我在两个表上都创建了值,为什么会出现唯一错误?
- java - Mapstruct 避免B 类中List 属性的循环问题