hello i’m trying to using sqlite with unity, but without any success.
i had used this youtube tutorial
but at the end i always get this error
Loading assembly failed: "Assets/Assemblies/Mono.Data.Sqlite.dll" reason: File does not contain a valid CIL image
Loading assembly failed: "Assets/Assemblies/System.Data.dll" reason: File does not contain a valid CIL image
i remember to get this working on unity 2018 or 2019, but don’t know what is wrong now.
any ideas what i need to do to get ride of this error ?
Hey guys, if you’re still having problems this was what worked for me. The issue for me was copying the correct version of the Mono.Data.Sqlite.dll to your game.
Nearly every SQlite Unity tutorial says to go to ” \Unity \Editor\Data\Mono\lib\mono\2.0 ” and copy the “Mono.Data.Sqlite.dll.” However most of those tutorials were written years ago and the folder structure doesn’t look like that anymore. Also, there’s multiple versions of the “Mono.Data.Sqlite.dll” in the Unity folder now. The version that worked for me and stopped the errors was located in
“C:\Program Files\Unity\Hub\Editor\2021.1.0b8\Editor\Data\MonoBleedingEdge\lib\mono\unityjit”
After that I had to restart the program, but the “CIL Image” error was gone.
The library I’m using
(Mono.Data.Sqlite.dll file.
Unity\Hub\Editor\2022.3.2f1\Editor\Data\MonoBleedingEdge\lib\mono\unityjit-win32)
always treats the INTEGER data type in the database as Int64.
Normally, for INTEGER data types that do not exceed 32 bits (as long as you don’t insert a number greater than 2,147,483,647), you would check if the data type is INTEGER with (fieldType == typeof(int)), and read the data with reader.GetInt32.
However, as initially explained, this particular library always treats the INTEGER type as Int64. Therefore, you must check with (fieldType == typeof(long)), and read the data using reader.GetInt64.