Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question problems trying to use sqlite with unity 2020.2.2

Discussion in 'Scripting' started by enzoravo, Jan 24, 2021.

  1. enzoravo

    enzoravo

    Joined:
    Jun 25, 2013
    Posts:
    284
    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

    Code (csharp):
    1.  
    2. Loading assembly failed: "Assets/Assemblies/Mono.Data.Sqlite.dll" reason: File does not contain a valid CIL image
    3.  
    4. Loading assembly failed: "Assets/Assemblies/System.Data.dll" reason: File does not contain a valid CIL image
    5.  
    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 ?

    thanks in advance for all the help
     
    Jeongyeon99 likes this.
  2. enzoravo

    enzoravo

    Joined:
    Jun 25, 2013
    Posts:
    284
    sorry for the bump, but i need some help with this
     
  3. ainulmuarifins

    ainulmuarifins

    Joined:
    Aug 7, 2019
    Posts:
    1
    Me to same error, help me please.
    Thanks advance
     
  4. teasully

    teasully

    Joined:
    Nov 26, 2016
    Posts:
    16
    Same issue here. Using Unity 2020.2.7f1
     
  5. rhenevers

    rhenevers

    Joined:
    Jan 1, 2018
    Posts:
    1
    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.o_O 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.

    I watched this video in particular as well to help set it up.

    Hope that helps folks. :D
     
    Last edited: Mar 30, 2021
  6. Borsuk85

    Borsuk85

    Joined:
    Feb 19, 2018
    Posts:
    1
    Can confirm this version doesn't spit out an error. Thanks!
     
  7. zim22

    zim22

    Joined:
    Feb 25, 2018
    Posts:
    44
    The DLL from "unityjit-win32" folder worked for me
    Thanks guys!
     
  8. waizui

    waizui

    Joined:
    Dec 12, 2018
    Posts:
    13
    thanks a lot!!
     
  9. florinel2102

    florinel2102

    Joined:
    May 21, 2019
    Posts:
    75
    I imported sqlite into my project a while back, but I got this error out of nowhere today. Thanks!
     
  10. Jeongyeon99

    Jeongyeon99

    Joined:
    Sep 10, 2023
    Posts:
    2

    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.

    I've wasted hours working on this issue with GPT.