Closed JohnSpencerTerry closed 5 years ago
Not related to this bug but is there any reason you are creating the CosmosClient for each call? The best practices recommend using a singleton. It avoids getting the caches for each new instance.
Thanks. I saw that but I figured I could pretty quickly refactor to inject it as a singleton instance later. The project that contains this code is a collection of class libraries that we use in a few asp net projects, so I'd rather save that for last. I'm pretty sure you should be able to create the client for each call though, if you want.
Same here, only happens in .net 4.7.2 project, not in netcoreapp2.2
Happens here as well, 4.6.2, without a using statement.
@ausfeldt do you have any suggestions?
Same, .NET Standard 2.0 project.
Root cause found. Working on an action plan now.
Thanks for the quick turn around. Appreciate the help!
We are in the process of upgrading from the 2.x document client to the 3.1 Cosmo client. I have created a repository class to generalize/isolate some of the cosmo sdk code. In my upsert method, I am attempting to construct the cosmo client in a using statement - this seemed to be supported by documentation and runs properly when NOT DEBUGGING.
To Reproduce I don't want to share the full code base if I can avoid it. My test is set up this this:
Which calls a collection specific repo class (basically just a configured wrapper for the actual cosmo repo class we have):
Which then calls my actual cosmo connection class:
The using statement is where things go bad for me. I get the following error as soon as it hits the using statement:
Expected behavior I should be able to debug my methods and skip over unmanaged code or get an exception that I can act on (if my call signature is wrong, etc).
Actual behavior Exception is thrown when debugging from a unit test but exception does not occur if the test is run without debugging. Information is persisted to cosmo repo as expected when "Run", but fails when "Debug".
Environment summary SDK Version: Microsoft.Azure.Cosmos 3.1.0 xunit 2.4.0 / .NET Framework 4.71 OS Version: Windows 10 17134.885
Additional context Please let me know if I've excluded any critical details. Thanks