Search code examples
monomonomac

Can't find System.Data.SQLite in MonoMac project


I'm trying to use a SQLite database in a MonoMac program (with the intent of reusing the database in a MonoTouch app).

I've tried two different ORMs, and both fail with the same issue. Searching around online, I discovered the MONO_LOG_LEVEL=debug flag, and a lot of information, but I can't quite get it working.

Currently, I'm referencing Mono.Data.SQLite, but from what I've found, it seems that that is just a wrapper for a system-specific version.

Here's the error output:

Mono: The request to load the assembly System.Data v2.0.0.0 was remapped to v4.0.0.0 Mono: Assembly Loader probing location: '/Library/Frameworks/Mono.framework/Versions/2.10.9/lib/mono/gac/System.Data/4.0.0.0_b77a5c561934e089/System.Data.dll'. Mono: Image addref System.Data[0x62ada0] -> /Library/Frameworks/Mono.framework/Versions/2.10.9/lib/mono/gac/System.Data/4.0.0.0_b77a5c561934e089/System.Data.dll[0xbd5600]: 2 Mono: Assembly System.Data[0x62ada0] added to domain SQLTest.exe, ref_count=1 Mono: AOT failed to load AOT module /Library/Frameworks/Mono.framework/Versions/2.10.9/lib/mono/gac/System.Data/4.0.0.0_b77a5c561934e089/System.Data.dll.dylib: dlopen(/Library/Frameworks/Mono.framework/Versions/2.10.9/lib/mono/gac/System.Data/4.0.0.0_b77a5c561934e089/System.Data.dll.dylib, 9): image not found

Mono: Assembly Loader loaded assembly from location: '/Library/Frameworks/Mono.framework/Versions/2.10.9/lib/mono/gac/System.Data/4.0.0.0_b77a5c561934e089/System.Data.dll'. Mono: Config attempting to parse: '/Library/Frameworks/Mono.framework/Versions/2.10.9/lib/mono/gac/System.Data/4.0.0.0_b77a5c561934e089/System.Data.dll.config'. Mono: Config attempting to parse: '/Library/Frameworks/Mono.framework/Versions/2.10.9/etc/mono/assemblies/System.Data/System.Data.config'. Mono: Assembly Ref addref Catnap[0x6213c0] -> System.Data[0x62ada0]: 2 Mono: Assembly Ref addref System.Data[0x62ada0] -> mscorlib[0x1001d90]: 6 Mono: Assembly Loader probing location: '/Library/Frameworks/Mono.framework/Versions/2.10.9/lib/System.Data.SQLite.dll'. Mono: Assembly Loader probing location: '/Library/Frameworks/Mono.framework/Versions/2.10.9/lib/System.Data.SQLite.exe'.

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Data.SQLite' or one of its dependencies. The system cannot find the file specified. File name: 'System.Data.SQLite' at System.AppDomain.Load (System.String assemblyString, System.Security.Policy.Evidence assemblySecurity, Boolean refonly) [0x00000] in :0 at System.AppDomain.Load (System.String assemblyString) [0x00000] in :0 at (wrapper remoting-invoke-with-check) System.AppDomain:Load (string) at System.Reflection.Assembly.Load (System.String assemblyString) [0x00000] in :0 at Catnap.Database.BaseDbAdapter.ResolveConnectionType (System.String connectionTypeAssemblyName) [0x00000] in :0 at Catnap.Database.Sqlite.BaseSqliteAdapter..ctor (System.String connectionTypeAssemblyName) [0x00000] in :0 at Catnap.Database.Sqlite.SqliteAdapter..ctor () [0x00000] in :0 at Catnap.DbAdapter.get_Sqlite () [0x00000] in :0 at YAData.Connection.Connect () [0x00000] in :0 at SQLTest.MainClass.Main (System.String[] args) [0x00000] in :0

I've tried adding a config file with

<configuration>
   <dllmap dll="sqlite3" target="/usr/local/lib/libsqlite3.0.dylib" os="!windows"/>
</configuration>

to the application, and I've tried modifying /Library/Frameworks/Mono.framework/Versions/2.10.9/etc/mono/config, but nothing has worked. It's still looking in the wrong places and not finding SQLite.

Help please?


Solution

  • I still don't know why it was looking for System.Data.SQLite, but I recompiled one of the ORMs myself rather than using the provided dll, and it worked. I'm sure some of the problem was that I was using the MonoTouch dll in a MonoMac project. Recompiling CoolStorage (which uses Mono.Data.Sqlite instead of System.Data.SQLite) resolved it.

    If anyone can give me an explanation, I'll switch accepted answers.

    On with the code!