MongoDB C# Driver: Cannot build after update from 2.27 to 2.28

Since the past year, we have updated regularly the MongoDB C# driver from version 2.20 up to 2.27.
All updates had no issues.

More recently, when trying to update the NuGet package from version 2.27 to 2.28, the solution does not build with the several errors.

Examples:

The type ‘IMongoCollection<>’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘MongoDB.Driver, Version=2.19.1.0, Culture=neutral, PublicKeyToken=null’

The type ‘IFindFluent<,>’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘MongoDB.Driver, Version=2.19.1.0, Culture=neutral, PublicKeyToken=null’

‘IAggregateFluent<>’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘MongoDB.Driver, Version=2.19.1.0, Culture=neutral, PublicKeyToken=null’

If we revert back to version 2.27 the solution builds fine.

The package is: MongoDB.Driver, and was obtained from this source: NuGet Gallery | MongoDB.Driver 2.28.0

The following image shows the package that was updated (MongoDB.Driver 2.28) and the errors after building the solution:

Was anyone with a similar issue? If so, were you able resolve it?

1 Like

I have noticed the same issue today when upgraded to 2.28. I am using AspNetCore.HealthChecks.MongoDb package which was updated with mongo db v2.28 5 days ago.

Didn’t have any luck fixing it. yet.

Hi, I’m also experiencing this issue with one of our dependencies. We’re using HotChocolate for graphql. Since updating to 2.28 we can no longer reference the dependency.

I have tried to fork the repository. But it seems that HotChocolate itself has a dependency that also needs MongoDb to be bumped. I forked the repo and opened a PR for it.

I was expecting to see more discussion about this online. It seems like this should have been marked as a breaking change.

Hi,

Thank you for bringing this to our attention, we just posted more details about this here. Sorry for the inconvenience caused but please feel free to reach out if you are blocked.

Thanks,

Rishit.

It seems we will be stuck on version 2.27.0 and we’ll definitely not fork third party libs.
It’s a shame that this was not flagged as a breaking change and the major version wasn’t bumped.

I was getting this with HotChocolate and solved by upgrading the following libs via nuget to pre-release ‘14.0.0-rc.1’
HotChocolate.AspNetCore
HotChocolate.Data.MongoDb

Underlying issue is 3rd party (HC) usage of MongoDb assemblies, i.e. v2.28 strong naming.