c# - 表仅在真实设备上没有(公共(public))列

标签 c# ios iphone xamarin sqlite-net

我有最简单的应用程序,我想在我全神贯注之前在我的设备上试用它们。但是,当我在我的 iPhone 上运行它时(与我的 macbook 上的模拟器相对),我收到了最奇怪的错误消息。

Table has no (public) columns .

我正在使用 SQLite.Net PCL,我是从 git hub 构建它的,因为我遇到了一些问题,因为它没有用于 IOS 的平台 dll。

相关代码。

在我的模型中我有这个:

public class Setting
{
    [PrimaryKey, AutoIncrement]
    public long Id { get; set; }

    [Indexed]
    public string Key { get; set; }

    public string Value { get; set; }

}

抛出此错误消息的代码很简单:

using (SQLiteConnection db = GetCon ()) {

            db.CreateTable<Setting> ();
}

但在我看来,最奇怪的是这段代码在模拟器上运行良好,但在 iphone 本身上崩溃了。

如果有人有一些想法会很棒。

编辑: 此错误是在 this file 上的 SQLite.Net-PCL 库上引发的第 380 行,但在设备上而不是模拟器上。

最佳答案

对于可能对此有疑虑的其他人,我找到了问题的答案。问题在于 Type 没有任何属性(所讨论的类型是简单模型类)。知道这是垃圾后,我找到了以下链接,这些链接提供了更多信息,我将在这篇文章中涉及这些信息,以防链接失效:

Type.GetProperties returning nothing

NOTE: Be careful with assembly linker

If you're building with linker enabled you may need to use the class somewhere, so it will not be ripped off at compile time. Sometimes, only instantiating the class in your code is not enough, the linker may detect that the instance is never used and will remove it anyway.

http://developer.xamarin.com/guides/ios/advanced_topics/linker/

The linking process can be customized via the linker behavior drop-down in Project Options. To access this double-click on the iOS project and browse to iOS Build > Linker Options, as illustrated below (see link for details)

我暂时将其取消链接,但是,我会在发布前尝试让链接器忽略这些类。感谢您的帮助。

关于c# - 表仅在真实设备上没有(公共(public))列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30059344/

相关文章:

c# - NSubstitute 使用一个类的真实实例作为替代,除了一个方法

c# - 使用usings在asp中发送电子邮件

ios - 类型 'ViewController' 不符合协议(protocol) 'FBSDKLoginButtonDelegate'

iphone - 如何在资源文件夹下以编程方式从 nsmutablearray 创建属性列表?

c# - MessageBox 不推荐在 MVVM 应用中使用?

c# - ASP.NET 4.6 中的 CSS 问题

ios - uicollectionview - 数据自动加载而不调用 reloaddata

ios - 如果我在 IOS Swift 上有位置坐标信息,我们如何检索 PlaceID

iOS 使 VPN 服务器地址可变

javascript - 如何使用 dashcode 将 Quicktime 电影嵌入到 iPhone Web 应用程序中?