Skip to content

Commit cc6dd60

Browse files
.Net: Fix postgres memory store dispose (#3177)
### 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 <[email protected]>
1 parent 49e057f commit cc6dd60

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎dotnet/src/Connectors/Connectors.Memory.Postgres/PostgresMemoryStore.cs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,9 @@ protected virtual void Dispose(bool disposing)
210210
{
211211
if (disposing)
212212
{
213-
this._dataSource?.Dispose();
213+
// Avoid error when running in .Net 7 where it throws
214+
// Could not load type 'System.Data.Common.DbDataSource' from assembly 'Npgsql, Version=7.*
215+
(this._dataSource as IDisposable)?.Dispose();
214216
}
215217
}
216218

0 commit comments

Comments
 (0)