I’ve started upgrading our solution to Couchbase 2.1 from 1.4
(BTW - the changes are quite nice - thread safety, better live query semantics, indexes, selections etc).
I’ve modified the shared CoreLibrary code, and am trying to get the CoreLibrary unit tests working. I’m getting a DllNotFound for LiteCore. I’m sure I’m missing something obvious here.
Fortunately I’ve reproduced the problem in a new minimal project, so I’ll focus troubleshooting on that minimal project.
Environment:
- MacOS (the projects build for iOS and Mac, but just focusing on Mac at the moment).
- All software, all packages, all OS’s up to date.
- Using Visual Studio 7.7.2.build 21
- Couchbase Lite 2.1.2
I created a minimal UnitTest project with a single file, and a single test:
using NUnit.Framework;
using System;
using Couchbase.Lite;
namespace CBTester
{
[TestFixture()]
public class Test
{
Database db;
[OneTimeSetUp()]
public void OneTimeSetUp()
{
Couchbase.Lite.Support.NetDesktop.Activate();
}
[SetUp()]
public void SetUp()
{
db = new Database("test");
}
[Test()]
public void TestCase()
{
var doc = new MutableDocument();
doc.SetString("var", "variable value");
doc.SetInt("num", 4);
db.Save(doc);
}
}
}
I added the following packages (plus dependencies):
- Couchbase.Lite
- Couchbase.Lite.Support.NetDesktop
- NUnit
This reproduces the problem. Here is the exact error message:
System.TypeInitializationException : The type initializer for 'Couchbase.Lite.Sync.HTTPLogic' threw an exception.
----> System.DllNotFoundException : LiteCore
I’ve scanned the forums on this problem. It seems that there are a couple of things that have fixed it for some people:
- an older version of couchbase had some issues (I’m running 2.1.2 - the latest).
- mixing versions of couchbase across projects within a solution. I’ve updated all project’s packages to couchbase 2.1.2 (some of course wont build yet).
I have checked - libLiteCore.dylib does exist in the bin/Debug folder and is identical to the one in the nuget packages folder:
$ cmp CBTester/bin/Debug/libLiteCore.dylib ~/.nuget/packages/couchbase.lite.support.netdesktop/2.1.2/runtimes/osx-x64/native/libLiteCore.dylib
$ echo $?
0
I can see in the application output that it is not loading libLiteCore, although you can see it load all the other Couchbase libraries:
...
Thread started: EventPumpThread #10
Thread started: NonParallelWorker #11
Loaded assembly: /Users/Paul/Dev/Test/CBTester/bin/Debug/Couchbase.Lite.dll
Loaded assembly: /Users/Paul/Dev/Test/CBTester/bin/Debug/netstandard.dll
Loaded assembly: /Users/Paul/Dev/Test/CBTester/bin/Debug/Couchbase.Lite.Support.NetDesktop.dll
Loaded assembly: /Users/Paul/Dev/Test/CBTester/bin/Debug/SimpleInjector.dll
Thread finished: EventPumpThread #10
Thread finished: NonParallelWorker #11
Thread finished: #3
...
Does anyone have any ideas as to how to fix this?
Many thanks.
Paul