Skip to content

Fix #20 and #21: file association + clipboard copy#22

Merged
aclinick merged 1 commit into
mainfrom
fix/20-21-clipboard-and-fta
Jun 8, 2026
Merged

Fix #20 and #21: file association + clipboard copy#22
aclinick merged 1 commit into
mainfrom
fix/20-21-clipboard-and-fta

Conversation

@aclinick

@aclinick aclinick commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Closes #20 and #21.

#20 — Right-click Open with MSIXplainer

Registers .msix / .msixbundle / .appx / .appxbundle via windows.fileTypeAssociation so Explorer can hand a file to the app. MainPageViewModel.LoadPackageFromPath is now public and shared by the picker and file activation. App.OnLaunched captures the activation path BEFORE constructing MainWindow so MainPage_Loaded can consume it synchronously.

#21 — Copy button did nothing

Clipboard.SetContent was throwing CO_E_NOTINITIALIZED (0x800401F0). Root cause: Program.cs Main was marked [MTAThread]. Because the csproj sets DISABLE_XAML_GENERATED_MAIN, the auto-generated [STAThread] Main is suppressed and ours wins. Everything else (XAML, bindings, pickers) ran fine on MTA but WinRT OLE-backed APIs refuse to. One-line fix: [STAThread] — with a guardrail comment so nobody flips it back.

Testing

  • 149/149 Core tests pass.
  • Manual: file association and Copy verified locally via BuildAndRun.ps1.

#20: Register .msix/.msixbundle/.appx/.appxbundle as supported file types

via a windows.fileTypeAssociation extension in Package.appxmanifest. Right-

click `Open with MSIXplainer` now launches the app and loads the package.

Wiring:

* MainPageViewModel.LoadPackageFromPath(string) extracted as public so it

  can be reused by the picker and by file activation.

* App.OnLaunched captures PendingFileActivationPath from

  AppInstance.GetCurrent().GetActivatedEventArgs() BEFORE new MainWindow()

  so the path is available when MainPage_Loaded fires.

* MainPage_Loaded calls App.ConsumePendingFileActivationPath() and

  invokes the VM. Avoids a DispatcherQueue.TryEnqueue race where the

  lambda ran before Frame.Content was set.

#21: WinUI 3 Clipboard.SetContent was throwing CO_E_NOTINITIALIZED

(0x800401F0). Root cause: Program.cs Main was marked [MTAThread]. Because

the .csproj sets DISABLE_XAML_GENERATED_MAIN, the auto-generated [STAThread]

Main is suppressed and our hand-written one wins. Everything else

(XAML, bindings, pickers) worked on MTA, but WinRT OLE-backed APIs like

DataTransfer.Clipboard refuse to run there. One-line fix: [STAThread].

Added a comment in Program.cs so nobody silently flips it back.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@aclinick aclinick enabled auto-merge (squash) June 8, 2026 19:06
@aclinick aclinick merged commit 3eef491 into main Jun 8, 2026
2 checks passed
@aclinick aclinick deleted the fix/20-21-clipboard-and-fta branch June 8, 2026 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add the ability to right-click on an MSIX/MSIXBundle and open with MSIXplainer

1 participant