semantic-kernel icon indicating copy to clipboard operation
semantic-kernel copied to clipboard

.Net:Bug: Could not load type 'MongoDB.Driver.MongoClientBase' from assembly 'MongoDB.Driver, Version=3.3.0.0, Culture=neutral, PublicKeyToken=94992a530f44e321'

Open futugyou opened this issue 6 months ago • 5 comments

Describe the bug Microsoft.SemanticKernel.Connectors.MongoDB 1.59.0-preview MongoDB.Driver 3.3.0 DI will report an error when getting the VectorStore implementation class

MongoDB.Driver 2.30.0 is ok

Platform

  • Language: C#
  • Source: Microsoft.SemanticKernel.Connectors.MongoDB 1.59.0-preview MongoDB.Driver 3.3.0

Additional context fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1] An unhandled exception has occurred while executing the request. System.TypeLoadException: Could not load type 'MongoDB.Driver.MongoClientBase' from assembly 'MongoDB.Driver, Version=3.3.0.0, Culture=neutral, PublicKeyToken=94992a530f44e321'. at Microsoft.Extensions.DependencyInjection.MongoServiceCollectionExtensions.<>c__DisplayClass5_0.<AddKeyedMongoVectorStore>b__0(IServiceProvider sp, Object _) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(ServiceIdentifier serviceIdentifier) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(ServiceIdentifier serviceIdentifier, ServiceProviderEngineScope serviceProviderEngineScope) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetRequiredKeyedService(Type serviceType, Object serviceKey, ServiceProviderEngineScope serviceProviderEngineScope) at Microsoft.Extensions.DependencyInjection.ServiceProviderKeyedServiceExtensions.GetRequiredKeyedService[T](IServiceProvider provider, Object serviceKey) at Microsoft.Extensions.DependencyInjection.MongoServiceCollectionExtensions.<>c.<AddKeyedMongoVectorStore>b__5_1(IServiceProvider sp, Object key) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(ServiceIdentifier serviceIdentifier) at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType) at lambda_method20(Closure, IServiceProvider, Object[]) at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.<>c__DisplayClass6_0.<CreateControllerFactory>g__CreateController|0(ControllerContext controllerContext) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext) at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider) at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)

futugyou avatar Jul 12 '25 16:07 futugyou

This is because Semantic Kernel supports .NET Framework 4.6.2 but MongoDB C# Driver 3,x requires .NET Framework 4.7.2 or later.

damieng avatar Sep 23 '25 14:09 damieng

Same cause as https://github.com/microsoft/semantic-kernel/issues/11652

damieng avatar Sep 23 '25 14:09 damieng

@damieng wanted to check where we are on this - do you need anything from us?

roji avatar Oct 29 '25 16:10 roji

We've talked at length and supporting 4.6.2 is a no-go for us for a number of previously-stated reasons.

I think if you're okay with the min req for the Semantic Kernel MongoDB driver changing to 4.7.2 then we can submit a PR.

As well as some new features it also has made the test runs a lot more stable on our end.

damieng avatar Oct 29 '25 16:10 damieng

Absolutely - as discussed you're the ones best-placed to make decisions for what you support and what you don't. Definitely feel free to submit a PR for that.

roji avatar Oct 29 '25 19:10 roji