Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

UnityScript2CSharp and unmanaged dll

Discussion in 'Experimental Scripting Previews' started by mgstauff, Apr 16, 2018.

  1. mgstauff

    mgstauff

    Joined:
    Sep 6, 2017
    Posts:
    59
    I've taken over an old js project and am trying to convert it to C#.
    It uses sqlite and thus sqllite3.dll

    When I run the conversion script I get these errors:

    Conversion aborted due to compilation errors:
    C:\Users\mgsta\Box Sync\Penn\IBI\3dHeatMap\3DHM-proj-Csharp\Assets\Convergence Assets\Scripts\HeatVRML.js(3,8): BCE0021: Namespace 'Mono.Data.Sqlite' not found, maybe you forgot to add an assembly reference?
    C:\Users\mgsta\Box Sync\Penn\IBI\3dHeatMap\3DHM-proj-Csharp\Assets\Convergence Assets\Scripts\HeatVRML.js(104,22): BCE0018: The name 'SqliteDataReader' does not denote a valid type ('not found').
    C:\Users\mgsta\Box Sync\Penn\IBI\3dHeatMap\3DHM-proj-Csharp\Assets\Convergence Assets\Scripts\HeatVRML.js(105,26): BCE0018: The name 'SqliteConnection' does not denote a valid type ('not found').
    C:\Users\mgsta\Box Sync\Penn\IBI\3dHeatMap\3DHM-proj-Csharp\Assets\Convergence Assets\Scripts\HeatVRML.js(106,21): BCE0018: The name 'SqliteCommand' does not denote a valid type ('not found').
    C:\Users\mgsta\Box Sync\Penn\IBI\3dHeatMap\3DHM-proj-Csharp\Assets\Convergence Assets\Scripts\HeatVRML.js(293,22): BCE0005: Unknown identifier: 'SqliteConnection'.

    I tried adding a ref to the dll using the '-r' option because I didn't know what else to do. And unsurprisingly (since if I understand correctly, an assembly should just be compiled IL code, and my sqlite3.dll is an unmanaged binary?) it didn't work:

    Format of the executable (.exe) or library (.dll) is invalid.

    Does anyone have any suggestions?
     
  2. AdrianoVerona_Unity

    AdrianoVerona_Unity

    Unity Technologies

    Joined:
    Apr 11, 2013
    Posts:
    317
    Hi @mgstauff

    The error messages means the converter could not resolve the types used to access sqllite.

    It looks like to me that you need to reference Microsoft.Data.Sqlite.dll or Mono.Data.Sqlite.dll (not sure which one your project uses, if any of those at all)

    Are you running the tool, from command line? Or are you using the Unity Editor integration ?

    Best

    Adriano
     
  3. mgstauff

    mgstauff

    Joined:
    Sep 6, 2017
    Posts:
    59
    OK, I see. My project imports Mono.Data.Sqlite.

    I was referencing the sqlite3.dll in my project Plugins folder. But as I'm starting to understand, that's an unmanaged binary, and I need to ref a managed dll that wraps/refs the actual unmanaged code in sqlite3.dll?

    Googling Mono.Data.Sqlite.dll brought me to the Mono project sqlite page, but no download of this file. It just pointed to download of the sqlite download with sqlite.dll (that I'd gotten previously to get a 64-bit version).

    I searched in the Unity install dir and found many Mono.Data.Sqlite.dll files. Ref'ing one of these from the UnityScript2CSharp script works.

    Does it matter much which one I ref? There are many versions (many under MonoBleedingEdge folder which I figured were best to skip). I went with:

    C:\Program Files\Unity\Editor\Data\Mono\lib\mono\unity\Mono.Data.Sqlite.dll

    I'm using the command line tool. I couldn't figure out how to run it from the Editor. Does it make a difference?

    Thanks for your help!

    -M
     
  4. AdrianoVerona_Unity

    AdrianoVerona_Unity

    Unity Technologies

    Joined:
    Apr 11, 2013
    Posts:
    317
    Exactly. As you realized you need Mono.Data.Sqlite.dll or the ms equivalent (they simply use the native dll)

    For the conversion tool, as long as you don't get errors during the conversion, you can use any Mono.Data.Sqlite.dll

    It shouldn't. The Editor integration just makes it easier to run the conversion (and assumes some defaults for the parameters)

    Let me know if you hit other issues.

    Adriano
     
  5. mgstauff

    mgstauff

    Joined:
    Sep 6, 2017
    Posts:
    59
    Thanks for the help, Adriano. I've got the tool to run, now I'm just wading through issues I have to handle manually. :)
     
    AdrianoVerona_Unity likes this.