c# - 抛出了 'Foundation.You_Should_Not_Call_base_In_This_Method' 类型的异常

标签 c# xamarin xamarin.forms xamarin.ios xamarin-binding

我要整合freshChat在 xamarin IOS 中,所以我添加了 IOS 绑定(bind)库并添加了 ApiDefinition、LibFDFreshChatSDK.a & Struct 并从中创建 Dll。

复制生成的 DLL 并在 Xamarin IOS 中添加引用。

当我通过在参数中传递 AppId 和 AppKey 创建 FreshchatConfig 对象时,它会引发异常

"Exception of type 'Foundation.You_Should_Not_Call_base_In_This_Method' was thrown"


// @interface FreshchatConfig : NSObject
[BaseType(typeof(NSObject))]
[Model]
public interface FreshchatConfig
{
    // @property (nonatomic, strong) NSString * appID;
    [Export("appID", ArgumentSemantic.Strong)]
    string AppID { get; set; }

    // @property (nonatomic, strong) NSString * appKey;
    [Export("appKey", ArgumentSemantic.Strong)]
    string AppKey { get; set; }

    // @property (nonatomic, strong) NSString * domain;
    [Export("domain", ArgumentSemantic.Strong)]
    string Domain { get; set; }

    // @property (nonatomic, strong) NSString * themeName;
    [Export("themeName", ArgumentSemantic.Strong)]
    string ThemeName { get; set; }

    // @property (nonatomic, strong) NSString * stringsBundle;
    [Export("stringsBundle", ArgumentSemantic.Strong)]
    string StringsBundle { get; set; }

    // @property (assign, nonatomic) BOOL gallerySelectionEnabled;
    [Export("gallerySelectionEnabled")]
    bool GallerySelectionEnabled { get; set; }

    // @property (assign, nonatomic) BOOL cameraCaptureEnabled;
    [Export("cameraCaptureEnabled")]
    bool CameraCaptureEnabled { get; set; }

    // @property (assign, nonatomic) BOOL notificationSoundEnabled;
    [Export("notificationSoundEnabled")]
    bool NotificationSoundEnabled { get; set; }

    // @property (assign, nonatomic) BOOL teamMemberInfoVisible;
    [Export("teamMemberInfoVisible")]
    bool TeamMemberInfoVisible { get; set; }

    // @property (assign, nonatomic) BOOL showNotificationBanner;
    [Export("showNotificationBanner")]
    bool ShowNotificationBanner { get; set; }

    // @property (assign, nonatomic) BOOL responseExpectationVisible;
    [Export("responseExpectationVisible")]
    bool ResponseExpectationVisible { get; set; }

    // -(instancetype)initWithAppID:(NSString *)appID andAppKey:(NSString 
    *)appKey;
    [Export("initWithAppID:andAppKey:")]
    IntPtr Constructor(string appID, string appKey);
}

最佳答案

尝试从 FreshchatConfig 的 API 定义中删除 [Model],例如:

// @interface FreshchatConfig : NSObject
[BaseType(typeof(NSObject))]
public interface FreshchatConfig

关于c# - 抛出了 'Foundation.You_Should_Not_Call_base_In_This_Method' 类型的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57891963/

相关文章:

android - 如何验证 Xamarin/Android 应用程序中的字段

c# - 清除 Xamarin Forms 中的所有字段

xamarin - 已注册路线列表

c# - 获取 List<T> 中最常见的项目并在此之后排序

c# - 在网站项目中找不到 System.Net.Http

xamarin - XF Binding .. 未找到属性,但仅适用于我的 Android 应用程序,而不适用于 iOS

xamarin - ListView 的刷新命令不适用于绑定(bind)的 IRelayCommand

c# - SQL Server "Network Path Not Found"跨环境随机且不频繁发生

c# - LINQ的更快版本.Any()和.Count()

ios - 为 ScrollView 内的堆栈布局切换 IsVisible 在 Xamarin 表单 iOS 中无法正确更新