Missing method on IL2CPP build

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 believe that method should exist - can you submit a bug report for this issue?

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.

Iā€™m not sure, sorry. We will need to investigate the bug report to learn more.

The missing method on IL2CPP indeed seems to be the problem (still). Is there any update on this?

2 Likes

I donā€™t recall what the bug report number was for this one, so Iā€™m not sure, sorry!

@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.

Hi!Someone managed to solve this problem on version 2021.2 ?

1 Like

Hi all,

any news?

Thanks

1 Like

Hi! I have updated the unit to version 2021.2.4f1 and replaced Mono.Data.Sqlite.dll with sources

7703569ā€“965020ā€“Mono.Data.Sqlite.zip (101 KB)

Hi,

@xAvatarchikx , did you add these sources?

These ones

I have attached the Mono.Data.Sqlite.zip file above

@xAvatarchikx Did you add them to the Plugins folder ? It seems I get some compilation problems.

you still need to create a file csc.rsp in the Assets folder
and add a line to it
-r:System.Transactions.dll

@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.

Hi,

@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:

From Playing in Editor

  • EntryPointNotFoundException: sqlite3_libversion_number assembly: type: member:(null)

From running on the mobile:

  • 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)

Am I missing something?

Btw, I am using unity 2021.2.5f1 ā€¦

this seems the right choice:

it seems working everywhereā€¦ tested quickly on editor, standalone and android (on mobile)ā€¦

May someone confirm with my (quick) test? It would be really appreciatedā€¦

Thanks