When using 2021.2.0a20 and building using IL2CPP, if you use interop services, at the time of its disposal it finds a missing method (that should be located at mscorlib?), using link.xml to bypass stripping dont helps and the problem persists. Can be easily reproducible by using mono sqlite and trying to close a connection.
System.MissingMethodException: System.Runtime.InteropServices.Marshal::SetLastWin32Error(System.Int32)
at System.Runtime.InteropServices.CriticalHandle.Dispose (System.Boolean disposing) [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.InteropServices.SafeHandle.Dispose () [0x00000] in <00000000000000000000000000000000>:0
at Mono.Data.Sqlite.SQLite3.Close () [0x00000] in <00000000000000000000000000000000>:0
at Mono.Data.Sqlite.SQLite3.Dispose (System.Boolean bDisposing) [0x00000] in <00000000000000000000000000000000>:0
at Mono.Data.Sqlite.SqliteConnection.Dispose (System.Boolean disposing) [0x00000] in <00000000000000000000000000000000>:0
at System.ComponentModel.Component.Dispose () [0x00000] in <00000000000000000000000000000000>:0
I did send it, is there anyway i can make the method to work for now? Even if i do try catch (given its at close that the problem happens) i still cant use it (i was using 2020 LTS and it was working 100% fine), if i dispose any of the related stuff it gives error on the same place.
@LeonhardP Kindly pointed me to the bug report that was originally submitted for this issue. Unfortunately, our QA team could not reproduce it, so we did not take any action.
@jirimotejlek If you have a Unity project that will reproduce this issue that you can submit via a bug report, please do so. We would love to investigate this issue. Thanks!
After experimenting with this the whole day, I suspect that I (and potentially @Kunnogi ) are not using the correct libsqlite3.so or Mono.Data.Sqlite.dll compatible with the current 2021.2.0f version and itās causing this problem. In my case, I canāt open the connection to the database, receiving the same error as @Kunnogi - System.MissingMethodException: etcā¦) It worked correctly in 2021.1 as well as all 2020 versions.
Which Mono.Data.Sqlite.dll and libsqlite3.so should be used? Is there any guidance regarding how to set this this up?
Itās not like SQLite is some obscure tool, itās the most widely used embedded database in the world. Yet, there is literally hundreds of different posts on unity.com forums as well as elsewhere from devs struggling to make it work in Unity3D.
Can this be, for example, a package that the developer would install if they need sqlite support in their game?
We donāt have any documentation or guidance about the usage of SQLite from the Unity side. I think that Mono.Data.Sqlite.dll should work, but it is not something that we actively test with Unity either, so I canāt say for sure.
I suspect that would be possible. Iām not familiar with what C# bindings there are already for SQLite, but I see no reason why there could not be a Unity package which makes this work well.
@xAvatarchikx Thank you for your response, the compilation errors are gone :).Somehow in my case the android build, still expects the dll when running on the phone.
@xAvatarchikx , I have added the sources you mentioned (in /Assets/Plugins/Mono.Data.Sqlite_2.0/), csc.rsp included in Assets. I have created an assembly definition with a name Mono.Data.Sqlite in the root folder of the sources.
It compiles and build with no issues but at run-time I have got these errors:
The type initializer for āMono.Data.Sqlite.UnsafeNativeMethodsā threw an exception
Unable to load DLL āMono.Data.Sqlite.DLLā. Tried the load the following dynamic libraries: Unable to load dynamic library āMono.Data.Sqlite.DLLā because of 'Failed to open the requested dynamic library (0x06000000) dlerror() = dlopen failed: library āMono.Data.Sqlite.DLLā not found (from running on the mobile)