Cluster.ConnectAsync throws PlatformNotSupportedException

Hi, while using the SDK 3.0 .NET example, connecting to the Couchbase 6.5 community edition, Cluster.ConnectAsync throws a PlatformNotSupportedException. This goes for connecting to a local as well as a remote server. It does, however, authenticate.

Any thoughts as to what the cause of this could be?

@raymond.vanleeuwen -

Can you post the stacktrace? What operating system is the client running on? Also, is the client throwing the exception or is it logging it?

-Jeff

Hi Jeff,

Thanks for your quick reply. the local client is running on windows 12 R2 and the remove client is running on windows server 2016. Both produce the same exception.

Thanks for your help. See the stacktrace below.
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture)
at Couchbase.Core.DI.TransientServiceFactory.<>c__DisplayClass6_0.g__Factory|1(IServiceProvider serviceProvider)
at Couchbase.Core.DI.TransientServiceFactory.CreateService(Type requestedType)
at Couchbase.Core.DI.CouchbaseServiceProvider.GetService(Type serviceType)
at Couchbase.Core.DI.CouchbaseServiceProviderExtensions.GetRequiredService(IServiceProvider serviceProvider, Type type)
at Couchbase.Core.DI.SingletonServiceFactory.<>c__DisplayClass8_1.b__2(ParameterInfo p)
at System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext() at System.Linq.Buffer1…ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source)
at Couchbase.Core.DI.SingletonServiceFactory.<>c__DisplayClass8_0.g__Factory|1(IServiceProvider serviceProvider)
at Couchbase.Core.DI.SingletonServiceFactory.CreateService(Type requestedType)
at Couchbase.Core.DI.CouchbaseServiceProvider.GetService(Type serviceType)
at Couchbase.Core.DI.CouchbaseServiceProviderExtensions.GetRequiredService(IServiceProvider serviceProvider, Type type)
at Couchbase.Core.DI.CouchbaseServiceProviderExtensions.GetRequiredService[T](IServiceProvider serviceProvider)
at Couchbase.Cluster.<.ctor>b__19_0()
at System.Lazy1.CreateValue() at System.Lazy1.LazyInitValue()
at System.Lazy1.get_Value() at Couchbase.Cluster.UpdateClusterCapabilities() at Couchbase.Cluster.<Couchbase-Core-Bootstrapping-IBootstrappable-BootStrapAsync>d__42.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Couchbase.Cluster.<ConnectAsync>d__22.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()
at WindowsFormsApp1.Form1.d__3.MoveNext() in C:\Users\ray.vanleeuwen\source\repos\WindowsFormsApp1\WindowsFormsApp1\Form1.cs:line 76

Forgot to mention that I’m using the latest nuget package. Couchbase.NetClient 3.0.0.0

@raymond.vanleeuwen -

Once again, is this an uncaught exception or are you seeing it your logs? Can you post the exception message as well? What is the .NET version?

-Jeff

Hi Jeff,

The windows app is set to framework 4.6.1, and yes this is an uncaught exception .
image
Exception message: {“Exception has been thrown by the target of an invocation.”} (System.Reflection.TargetInvocationException)
Inner exception message: {“Operation is not supported on this platform.”} (PlatformNotSupportedException: )

Thanks, the .NET Framework version is likely the issue here as we targeted .NET Standard 2.0/2.1 with Sdk3. I’ll look deeper into it.

Hi Jeff,

Thanks for the feedback. Earlier I’ve used v2.7 and worked fine with the windows app.
It would be good to see that v3.0 can be used with NET framework 4.4 and up. We have a bunch of assemblies that provide functionality for our web sites. These assemblies utilise the Couchbase client.
I don’t think it would be feasible for us to port all of the assemblies to .NET Standard.
Cheers,
Ray

It should be compatible with .NET 4.6.1 and later. .NET Standard 2.0 is compatible with that target. However, I do know there are some quirks with that compatibility, any chance you can try targeting .NET 4.7.1 or later to see if it makes any difference?

Hi, I’ve tried 4.7.2 but Cluster.ConnectAsync throw an uncaught exception of FileNotFoundException - System.ValueTulip.

4.7.1 works, after a clean and a rebuild and reload of the DnsClient package.

Since we’re using Couchbase to cache list items, which could be content on a page as well as system config settings, would the 3.0 SDK be recommended for this kind of application? Unless I’m doing something wrong, I mean, it doesn’t appear to be very fast. Even in the web app targeting .Net Core 2.1. I’ve been using the example that’s on the 3.0 SDK web site page.

Cheers,
Ray

@raymond.vanleeuwen

I believe we’ve found the bug, and @jmorris has put in a fix. https://issues.couchbase.com/browse/NCBC-2478.

As to speed, the SDK should be blazing fast for cache operations. I use it personally for that type of operation all of the time. I would suspect there may be an issue with the implementation? The most frequent mistake I see is opening a connection to the cluster for every request. You should open it once during application startup and reuse it for the lifetime of the application. If you’re still having problems, I’d recommend opening up a new post with more details about your use case.

@btburnett3

Thanks for the heads up. In regards to the speed, I’m using the SDK example: https://docs.couchbase.com/dotnet-sdk/3.0/hello-world/start-using-sdk.html

I’m trying to implement Couchbase SDK 3.0 in SharePoint 2013 but SharePoint doesn’t cooperate very well with implementing async methods. Have you had any feedback from clients around implementing this SharePoint 2013, 2016 and SharePoint 2019? Or perhaps have some examples?

Cheers,
Ray