Skip to content

.Net: System.TypeLoadException Could not load type 'System.Data.Common.DbDataSource' from assembly 'Npgsql' #3121

Closed

Description

@QuentinRogerC2S

The application throws an unhandled exception related to the loading of System.Data.Common.DbDataSource from assembly 'Npgsql'. This happens when the application attempts to dispose of the PostgresMemoryStore.

To Reproduce
Inject an instance of IMemory store :

builder.Services.AddScoped<IMemoryStore>(provider =>
{
    var dataSourceBuilder = new NpgsqlDataSourceBuilder(builder.Configuration.GetConnectionString("PostgresConnectionString"));
    dataSourceBuilder.UseVector();
    return new PostgresMemoryStore(dataSourceBuilder.Build(), 1536);
});

Expected behavior
The application should smoothly dispose of the PostgresMemoryStore without any errors.

Platform

  • OS: Windows
  • IDE: Visual Studio
  • Language: C#
  • Source: Microsoft.SemanticKernel.Connectors.Memory.Postgres 1.0.0-beta1

Additional context

fail: Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HMU9S3SSK6LB", Request id "0HMU9S3SSK6LB:00000001": An unhandled exception was thrown by the application.
      System.TypeLoadException: Could not load type 'System.Data.Common.DbDataSource' from assembly 'Npgsql, Version=7.0.6.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7'.
         at Microsoft.SemanticKernel.Connectors.Memory.Postgres.PostgresMemoryStore.Dispose(Boolean disposing)
         at Microsoft.SemanticKernel.Connectors.Memory.Postgres.PostgresMemoryStore.Dispose()
         at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.DisposeAsync()
      --- End of stack trace from previous location ---
         at Microsoft.AspNetCore.Http.Features.RequestServicesFeature.<DisposeAsync>g__Awaited|9_0(RequestServicesFeature servicesFeature, ValueTask vt)
         at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.<FireOnCompleted>g__ProcessEvents|242_0(HttpProtocol protocol, Stack`1 events)
info: Microsoft.IdentityModel.LoggingExtensions.IdentityLoggerAdapter[0]

Activity

  1. changed the title [-]System.TypeLoadException Could not load type 'System.Data.Common.DbDataSource' from assembly 'Npgsql'[/-] [+].Net: System.TypeLoadException Could not load type 'System.Data.Common.DbDataSource' from assembly 'Npgsql'[/+] on Oct 10, 2023
  2. added a commit that references this issue on Nov 7, 2023
    cc6dd60
  3. moved this from Community PRs to Sprint: Done in Semantic Kernelon Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETIssue or Pull requests regarding .NET codebeta

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions