Open SpartaDeveloper93 opened 1 month ago
Hi @SpartaDeveloper93,
Sorry that this is causing issues for you. I am trying to reproduce this issue, but I am unable to do so. I've downloaded the MongoDB sample we have, and it seems it builds fine with v2.28.0.
Are you able to have a look at that sample and tell us what we need to modify to reproduce the issue?
@johnsimons
For the MongoDB database, you need to use the following lines
var persistence = endpointConfiguration.UsePersistence<MongoPersistence>(); persistence.MongoClient(new MongoClient( <MongoDbConnectionString> )); persistence.DatabaseName( <DatabaseName> );
The error comes on this line:
persistence.MongoClient(new MongoClient( <MongoDbConnectionString> ));
Hi @SpartaDeveloper93,
So we have investigated what the issue is with this, and it gets pretty interesting. So it seems the version 2.28.0 of the MongoDB.Driver library is now strong name (Yes I know, I thought strong name in dotnet world was not a thing anymore!) As far as we understand, this seems to cause this issue. If you instead reference v2.27.0 or any other version before 2.28.0 it does work!
This has implications as pointed out by you, if a new version of MongoDB.Driver is released to patch for example, a CVE, the customers won't be able to patch it directly in their code and need to wait for the 3rd party (in this case Particular) to upgrade their library to reference the patched version 😞
So, we are planning to touch basis with the MongoDB driver authors and point this out. In the meantime, we are trying to figure out if there are any workarounds and we will let you know what the outcome is.
I hope this makes sense.
@johnsimons , Yeah, it's weird that they will introduce breaking changes with a minor version updates. Thanks for investigating, it's not a big deal for us yet so we will keep our MongoDB library version to 2.27 for now.
@johnsimons, are there any updates?
Describe the bug
Description
We are using MongoDB for our Outbox Persistence and recently decided to update our MongoDB.Driver to latest version which is 2.28.0. As per the package dependencies of this library's version 4.0.0, it should have been compatible but results in build time error.
Expected behavior
Updating the MongoDB.Driver should not result in any code changes or build errors.
Actual behavior
The application starts throwing the following error during build:
Error CS0012 : The type 'IMongoClient' is defined in an assembly that is not referenced. You must add a reference to assembly 'MongoDB.Driver, Version=2.24.0.0, Culture=neutral, PublicKeyToken=null'.
Versions
NService.Storage.MongoDB -> 4.0.0 Please list the version of the relevant packages or applications in which the bug exists.
NServiceBus -> 9.0.1
Steps to reproduce
Relevant log output
No response
Additional Information
Workarounds
So, our workaround for this has been to use the below line in our PackageReference which resolved the issue for the time being:
<PackageReference Include="MongoDB.Driver" Version="[2.24.0, 2.28.0]"/>
Possible solutions
Additional information