Couchbase.Configuration.Client.ClientConfiguration.LoggerFactory missing in net45 dll

I have a NetStandard2.0 library that implements our caching logic. It has a dependency on Couchbase.Extensions.Caching (1.0.1). This library is used by a Web API project (netcore2.0) and works just fine.

However, this library is also referenced by a Windows Service project (framework 4.7.1). When the couchbase client is initialized by the DI container I get the following exception:

Method not found: 'Void Couchbase.Configuration.Client.ClientConfiguration.set_LoggerFactory(Microsoft.Extensions.Logging.ILoggerFactory)'.

How do I get the Framework 4.7.1 project to use the NetStandard2.0 version of Couchbase.NetClient.dll instead of the “net45” version?


Unfortunately, there isn’t a way to cause NuGet to install the .NET Standard version locally. It considers the net45 version a better fit (correctly for most users’ use cases). The fact that the logging surface area of the API is different between frameworks could possibly be considered a design flaw in the Couchbase SDK, but unfortunately it was necessary to maintain backwards compatibility when .NET Core support was added.

Your best solution would be to dual-build your .NET Standard package with a net45 and netstandard20 variant which handle the different logging approaches. It may be possible for the SDK to be updated with support for Microsoft.Extensions.Logging to the net45 variant, but it may pull in unwanted dependencies. I’m interested to hear other opinions on that. Even so, that would be a future release change, and wouldn’t help you immediately.

My caching package actually doesn’t reference any logging logic at all. However, I tried removing my NetStandard package completely and tried to use the Couchbase.Extensions.Caching nuget package directly from the Framework 4.7.1 project, but I get the same results.

It appears that using Couchbase.Extensions.Caching (and services.UseCouchbase() in particular) just don’t work in a Framework project at all.

It seems like it might be best to have 2 different NuGet packages if the public APIs are going to be different.

Any advice on how to initialize the SDK and wire up IDistributedCache to CouchbaseCache using IServiceCollection in a Framework 4.7.1 project would be greatly appreciated.

Ah, I see. Unfortunately, the Couchbase.Extensions packages were never designed/tested for running in .NET full framework. We’d have to modify those, probably at least Couchbase.Extensions.DependencyInjection, to dual build for net45 and netstandard20.

@jmorris thoughts?

So, this is the offending code:

I copied the ClusterProvider class into my project and removed that one line. I then bound IClusterProvider to my implementation and now it appears to be working (no error on initialization anyway).

Good call on the workaround, I should have thought of that!

@scott.roberts @btburnett3 -

Feel free to push a PR or create an issue on the github project. I’ll be releasing a GA sometime in the next week or so.