dotnet / aspire

Tools, templates, and packages to accelerate building observable, production-ready apps
https://learn.microsoft.com/dotnet/aspire
MIT License
3.91k stars 475 forks source link

MongoDB.Driver v3 breaks Aspire.MongoDB.Driver integration #6380

Open eerhardt opened 1 month ago

eerhardt commented 1 month ago

https://github.com/mongodb/mongo-csharp-driver/releases/tag/v3.0.0

The MongoDB .NET/C# driver team is pleased to announce our v3.0.0 release! The 3.0.0 release incorporates many user-requested fixes and improvements that have been deferred as backwards-incompatible, as well as internal improvements to pay down technical debt and improve maintainability. Additional major changes include removal of a large area of the public API (mainly from MongoDB.Driver.Core), which was not intended for public use. Removed APIs are marked as deprecated in v2.30.0 version. For all the breaking changes and for the upgrade guidlines, please see the upgrade guide.

We should follow the same approach as outlined in RabbitMQ.Client v7 breaks Aspire.RabbitMQ.Client component (dotnet/aspire#3956)

cc @sebastienros @radical @joperezr @DamianEdwards

eerhardt commented 1 month ago

Exception you get when using the 3.0.0 version of MongoDB.Driver with the Aspire integration:

System.IO.FileNotFoundException: Could not load file or assembly 'MongoDB.Driver.Core, Version=2.29.0.0, Culture=neutral, PublicKeyToken=94992a530f44e321'. The system cannot find the file specified.
File name: 'MongoDB.Driver.Core, Version=2.29.0.0, Culture=neutral, PublicKeyToken=94992a530f44e321'
   at Microsoft.Extensions.Hosting.AspireMongoDBDriverExtensions.CreateMongoClient(IServiceProvider serviceProvider, String connectionName, MongoDBSettings mongoDbSettings, Action`1 configureClientSettings)
   at Microsoft.Extensions.Hosting.AspireMongoDBDriverExtensions.<>c__DisplayClass5_0.<AddMongoClient>b__0(IServiceProvider sp) in /_/src/Components/Aspire.MongoDB.Driver/AspireMongoDBDriverExtensions.cs:line 113
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(ServiceIdentifier serviceIdentifier)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(ServiceIdentifier serviceIdentifier, ServiceProviderEngineScope serviceProviderEngineScope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at lambda_method2(Closure, Object, HttpContext)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
DamianEdwards commented 1 month ago

Is the plan to take #6381 for 9.0 GA? I'd think we should right?

eerhardt commented 1 month ago

Is the plan to take #6381 for 9.0 GA? I'd think we should right?

Yes, that was my plan. So people don't use the Aspire library with the 3.0.0 version of MongoDB.Driver.

paulomorgado commented 1 month ago

Is the plan to take #6381 for 9.0 GA? I'd think we should right?

Yes, that was my plan. So people don't use the Aspire library with the 3.0.0 version of MongoDB.Driver.

Why?

I would understand if below 3.0.0 would not be possible with Aspire 9.0, but not this. So, I need to choose between Aspire or MongoDB 3.0.0?

@JamesKovacs, MongoDB should provide a MongoDB.Driver.Core package with type forwarding to ease migration to MongoDb.Driver 3.0.0. As it is, it will break a lot of libraries and applications and delay (or prevent) the adoption of MongoDb.Driver 3.0.0. And out-of-the-box OpenTelemetry support.

eerhardt commented 4 weeks ago

Yes, that was my plan. So people don't use the Aspire library with the 3.0.0 version of MongoDB.Driver.

Why?

Because it doesn't work. See the above exception.