Couchbase 2.0 .NET 'No service for type 'Couchbase.Lite.DI.IDefaultDirectoryResolver' '

Hi,

I get the following error when creating a database:

var itemDatabase = new Database(“items”);

ex = {System.InvalidOperationException: No service for type 'Couchbase.Lite.DI.IDefaultDirectoryResolver' has been registered.
  at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService 

ex = {System.InvalidOperationException: No service for type 'Couchbase.Lite.DI.IDefaultDirectoryResolver' has been registered.
  at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService (System.IServiceProvider provider, Sy...

Are there any tips or hints on writing a DatabaseConfiguration?

Hi,

You can close this. I had misread the guidlines and forgot

            Context context = this.ApplicationContext;
            Couchbase.Lite.Support.Droid.Activate(context);

in MainActivity.cs

You likely won’t be the only one to encounter this problem. I should probably catch this exception and change it with something that reminds the user to do this.

1 Like

Hi borrden,

I have an extra question. I don’t want to flood the form with my questions so here goes:

How do you open a database in cbl 2.0? I see a function exists() that only returns a bool. In CBL1.5 you had the GetDatabase but that was in a Manager instance…

Thanks
Thomas

Check the code examples in the repo and in the docs. There is no more “opening” of the database. The constructor will automatically open it for you and disposing it will close it.

1 Like

Thank you very much for your help Sir. I spent a half hour searching for the 2.0.0-db011 build on github and finally found it

https://github.com/couchbase/couchbase-lite-net/tree/2.0.0-db011

For anyone else who is curious, instructions on getting it are in the releases section of the linked repo. There is a nuget feed that contains all the .NET DBs in it (note that some numbers are missing, those numbers just don’t exist for various reasons)

1 Like