Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Table has no (public) columns only on real device

I have the simplest of apps that I thought I would try on my device before I got too engrossed. However, I am getting the strangest error message when I run it on my iPhone (as apposed to the the emulator on my macbook).

Table has no (public) columns .

I am using the SQLite.Net PCL and I have built it from git hub as I had some problems with it not having the platform dlls for IOS otherwise.

Relevant code.

In my models I have this:

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

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

    public string Value { get; set; }

}

The code that throws this error message is the simple:

using (SQLiteConnection db = GetCon ()) {

            db.CreateTable<Setting> ();
}

but in my opinion the strangest thing is that this code works fine on the emulator but crashes the application on the iphone itself.

If anyone has some ideas that would be great.

EDIT: This error is thrown on the SQLite.Net-PCL library on this file line 380 but only on the device and not on the emulator.

like image 416
Daniel Casserly Avatar asked May 05 '15 17:05

Daniel Casserly


1 Answers

For others to whom this may concern, I found the answer to my problem. The issue was with the Type not having any properties (the type in question the simple model class). Knowing that to be rubbish I found the following links that gave more information which I will relate in this post in case the links go dead:

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)

I have for now left it to be unlinked, however, I will try before release to get the linker to ignore these classes. Thanks for all your help.

like image 154
Daniel Casserly Avatar answered Oct 05 '22 19:10

Daniel Casserly