DllNotFoundException: Could not find LiteCore.dll! Nothing is going to work!

Here’s how I produced the error.

  • Create a class library
  • Add a reference to CouchBaseLite
  • Create a WPF application
  • Add a reference to the class library in the WPF application
  • Run the application

The LiteCore.dll file in the bin\debug\x64 and bin\debug\x86 folders in the class library are not copied to the WPF application

Here’s the full error message.

System.TypeInitializationException
HResult=0x80131534
Message=The type initializer for ‘Couchbase.Lite.Internal.Logging.WriteLog’ threw an exception.
Source=Couchbase.Lite
StackTrace:
at Couchbase.Lite.Internal.Logging.WriteLog.get_To()
at Couchbase.Lite.DatabaseConfiguration.set_Directory(String value)
at InfrastructureLib.Repository.ExternalRepositoryServiceProvider.Inject() in C:\Users\REMOVED\Documents\GitHub\sqlserverapplication\InfrastructureLib\Repository\ExternalRepositoryServiceProvider.cs:line 42
at UserInterface.App.InfrastructureInjector() in C:\Users\REMOVED\Documents\GitHub\sqlserverapplication\UserInterface\App.xaml.cs:line 274
at UserInterface.App.OnStartup(StartupEventArgs e) in C:\Users\REMOVED\Documents\GitHub\sqlserverapplication\UserInterface\App.xaml.cs:line 126
at System.Windows.Application.<.ctor>b__1_0(Object unused)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

This exception was originally thrown at this call stack:
Couchbase.Lite.Support.NetDesktop.LoadLiteCore() in Activate.cs
[External Code]

Inner Exception 1:
TypeInitializationException: The type initializer for ‘LiteCore.Interop.Native’ threw an exception.

Inner Exception 2:
DllNotFoundException: Could not find LiteCore.dll! Nothing is going to work!
Tried searching in:
C:\Users\REMOVED\Documents\GitHub\sqlserverapplication\UserInterface\runtimes\win7-x86\native\LiteCore.dll
C:\Users\REMOVED\Documents\GitHub\sqlserverapplication\UserInterface\bin\Debug\x86\LiteCore.dll
C:\Users\REMOVED\Documents\GitHub\sqlserverapplication\UserInterface\bin\Debug\bin\x86\LiteCore.dll

@QsWZJuPYAh2Wh7dZ You will also need to add the Couchbase Lite Support nuget package depends on what platform you are working with. Here is the documentation FYI: Installing Couchbase Lite on .Net | Couchbase Docs

I read the documentation and I’m a bit confused.

Does the support package provide the LiteCore.dll file? If so, does the support package only need to only be installed in the project using Couchbase Lite or also in all projects referencing the project using Couchbase Lite? Thanks.