Skip to content

fix: handle when WinRT APIs are unavailable - #38612

Merged
AndriySvyryd merged 3 commits into
dotnet:mainfrom
BrycensRanch:main
Aug 15, 2026
Merged

AndriySvyryd merged 3 commits into
dotnet:mainfrom
BrycensRanch:main

Conversation

@BrycensRanch

@BrycensRanch BrycensRanch commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor
  • I've read the guidelines for contributing and seen the walkthrough
  • I've posted a comment on an issue with a detailed description of how I am planning to contribute and got approval from a member of the team
  • The code builds and tests pass locally (also verified by our automated build checks)
  • Commit messages follow this format:
        Summary of the changes
        - Detail 1
        - Detail 2

        Fixes #bugnumber
  • Tests for the changes have been added (for bug fixes / features)

The change is a small addition to an existing exception filter and doesn't introduce new behavior that requires unit testing. The exceptions being added are already handled conceptually by the existing "feature unavailable" logic.

  • Code follows the same patterns and style as existing code in this repo

Motivation

The existing code already catches exceptions from the initial WinRT call (e.g., TargetInvocationException and InvalidOperationException for unpackaged apps). However, Wine partially implements WinRT — it successfully returns a ApplicationData object from the first call, but then throws NotImplementedException when accessing the LocalFolder property. Since this exception isn't caught, the entire SqliteConnection type becomes unusable.

Note: System.Data.SQLite works fine under Wine because it doesn't attempt this WinRT trick. However, I love Microsoft.Data.Sqlite and I'm a programmer that daily drives Linux and want to test my application under Wine instead of an VM. It'd also fix ShareX's latest versions under Wine too.

Fixes #36343

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to make Microsoft.Data.Sqlite more resilient on Windows-like environments where WinRT APIs exist but are partially unavailable (e.g., Wine), by extending the static initialization logic that attempts to use Windows.Storage.ApplicationData.

Changes:

  • Adds exception handling intended to treat NotImplementedException/NotSupportedException as “WinRT feature unavailable” during WinRT probing in SqliteConnection’s static constructor.

@BrycensRanch

Copy link
Copy Markdown
Contributor Author

@dotnet-policy-service agree

@AndriySvyryd AndriySvyryd self-assigned this Aug 14, 2026
@AndriySvyryd

Copy link
Copy Markdown
Member

Marking as draft until it's updated

@AndriySvyryd
AndriySvyryd marked this pull request as draft August 14, 2026 20:43
@BrycensRanch

Copy link
Copy Markdown
Contributor Author

Updating, thank you for reminding me about this!

@BrycensRanch
BrycensRanch marked this pull request as ready for review August 14, 2026 21:11
@AndriySvyryd AndriySvyryd added this to the 12.0.0 milestone Aug 14, 2026
@BrycensRanch

Copy link
Copy Markdown
Contributor Author

Hello @AndriySvyryd, is it possible to reconsider this for .NET 11? It would be fantastic to include this modest, low-risk patch for Wine compatibility in the preceding release since it only addresses failure instances and has no effect on successful execution routes or current tests.

@AndriySvyryd AndriySvyryd modified the milestones: 12.0.0, 11.0.0 Aug 15, 2026

@AndriySvyryd AndriySvyryd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, this barely makes the cut.
Thanks for your contribution!

@AndriySvyryd
AndriySvyryd merged commit 26a12eb into dotnet:main Aug 15, 2026
14 of 15 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot modified the milestones: 11.0.0, 11.0-rc1 Aug 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Getting exceptions from SqliteConnection static constructor on Windows desktop [OUTDATED] [Guide] Get ShareX up and running on Linux

3 participants