ios - 找不到命名空间中的Xamarin.Forms类(仅在iOS上)

标签 ios xaml xamarin xamarin.forms

我有一个Xamarin.Forms解决方案,它由几个PCL和特定于设备的项目组成:

  • MyApp.Controls(便携式)
  • 帮助器(MyApp.Controls.Helper)
  • MyApp.App(便携式)
  • MyApp.iOS
  • MyApp.Android

  • MyApp.App是我的主要实现,在其中实现了App.xaml和所有Views / ViewModels。该项目引用MyApp.Controls并通过xmlns在XAML中引用此项目。 XAML引用在Android上工作正常,但在iOS上,我收到以下异常:
    controls:MyClass在xmlns中找不到clr-namespace:MyApp.Controls.Helper; assembly = MyApp.Controls

    我不知道为什么无法在iOS上解析“MyClass”。我正在使用Xamarin.Forms 2.3.3.180。

    最佳答案

    最可能的原因是程序集没有使用C#代码,因此编译器不包含它。您可以通过在AppDelegate中添加快速代码段来确认这一点。例如,

    new MyClass();
    

    只需在FinishedLaunching方法中添加一行,这样编译器就会知道您正在使用引用程序集中的代码并将包含。如果这确实是问题所在,则可以执行一些更漂亮的操作,例如在该库中包括Init方法。

    关于ios - 找不到命名空间中的Xamarin.Forms类(仅在iOS上),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41895699/

    相关文章:

    ios - 授权给 HealthKit 时,错误 '(_, _) -> Void' 无法转换为 'HealthManager'

    ios - 迅速: Grand-Central-Dispatch but code is executed on mainthread?

    c# - xaml 中使用的通用类型的 TypeConverter

    c# - SQLite:从列表中的对象中检索子元素

    ios - 如何使用第三方应用程序在 iPad 上实现分屏多任务处理?

    ios - 如何在 iOS Swift 中可靠地获取键盘高度?

    c# - Wpf 主从 ListView 绑定(bind)

    c# - 在 Wpf 中,如何将命令从按钮发送到子控件?

    azure - 如何在 Xamarin UWP 应用中检索 Toast 通知消息?

    ios - "' 当通过手势识别器呈现 View Controller 时,应用程序试图以模态方式呈现事件 Controller