Description
.NET Core is able to do this automatically, but .NET Framework fails to do so starting in 2.6.0. The reason for this is an inconsistency in Windows with what it actually defines with its compiler. On Windows 10, the NETFRAMEWORK define is present by default (which is what is used for testing) but on Windows Server 2012 (server variant of Windows 8.x which is used for building) it is not present and so the critical logic for loading the native LiteCore library is not compiled in and the result is that nothing works.
There are two workarounds here:
- Copying the proper native LiteCore.dll into the same directory as the outputted .NET application (After you build the app you can find the two in the x86 and x64 folders of the application output directory [e.g. bin/Debug/x64])
- This line of code will use reflection to call the proper method:
Type.GetType("Couchbase.Lite.Support.NetDesktop, Couchbase.Lite.Support.NetDesktop").GetMethod("LoadLiteCore", BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, null);