Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
QuentinRogerC2S opened this issue Oct 10, 2023 · 0 comments · Fixed by #3177
Labels
beta .NET Issue or Pull requests regarding .NET code

Comments

@QuentinRogerC2S
Copy link

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]
@shawncal shawncal added .NET Issue or Pull requests regarding .NET code triage labels Oct 10, 2023
@github-actions github-actions bot 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' Oct 10, 2023
@matthewbolanos matthewbolanos moved this to Community PRs in Semantic Kernel Oct 16, 2023
github-merge-queue bot pushed a commit that referenced this issue Nov 7, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
### Motivation and Context

<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->
Fix #3121

### Description

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
Convert to `IDisposable` to execute `Dispose`.

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄

---------

Co-authored-by: Roger Barreto <19890735+RogerBarreto@users.noreply.github.com>
@github-project-automation github-project-automation bot moved this from Community PRs to Sprint: Done in Semantic Kernel Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta .NET Issue or Pull requests regarding .NET code
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants