I’m trying to share all my business logic code across three applications: an android app, an iOS app, and a Winforms app. All three of these applications need access to a local Sqlite database, and I had assumed I could use Mono.Data.Sqlite for all three to accomplish this.
So, I’ve setup an Android class library along with a regular .NET class library, and linked the projects together. This works fine for everything except the Sqlite code. Am I not able to merely reference Mono.Data.Sqlite.dll and have it work in the Winforms application? If I do, it still doesn’t fix the following errors:
The type or namespace name ‘SqliteConnection’ could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name ‘SqliteDataReader’ could not be found (are you missing a using directive or an assembly reference?)
Now, I would think adding a reference to the Mono Sqlite DLL would have resolved that issue, but apparently not. It can’t even find the Mono namespace itself.
I am thinking that I may need a Mono.Data.Sqlite DLL that has been compiled specifically for Windows, and not Android. Is this correct? If so, can I find a pre-compiled binary somewhere (preliminary searches returned nothing useful).
Or will I have to write a wrapper for the SQLite code so that it just uses System.Data.SQLite in the Winforms app (which I am hoping to avoid, as the methods differ)? Will I have to do the same when deploying to MonoTouch? Is this going to be the case for almost all of the Mono framework?
I’m just trying to wrap my head around codebase sharing with Mono and how it applies to multiple platforms. This is my first major hurdle so far. My goal is to have essentially one codebase for all the logic, and then just write native UI code for each platform.
Thanks!
You can use Mono.Data.Sqlite on the desktop as well, but you probably want to reference the desktop version not the M4A version.
Simplest way to get it may be to download and install Mono on your desktop can grab the DLL from the install directory.
Note that your exact scenario does work, it’s what we do. We have a desktop DALC class library project, referencing the regular Mono.Data.Sqlite with all our data access code.
Next we have MonoTouch and Mono4Android projects in the same solution. They reference the platform versions of the Mono.Data.Sqlite assembly, and all our source files are simply linked in.
So we have one code base, and three assemblies (one for each platform).