Fix #20 and #21: file association + clipboard copy#22
Merged
Conversation
#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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #20 and #21.
#20 — Right-click
Open with MSIXplainerRegisters
.msix/.msixbundle/.appx/.appxbundleviawindows.fileTypeAssociationso Explorer can hand a file to the app.MainPageViewModel.LoadPackageFromPathis now public and shared by the picker and file activation.App.OnLaunchedcaptures the activation path BEFORE constructingMainWindowsoMainPage_Loadedcan consume it synchronously.#21 — Copy button did nothing
Clipboard.SetContentwas throwingCO_E_NOTINITIALIZED(0x800401F0). Root cause:Program.csMainwas marked[MTAThread]. Because the csproj setsDISABLE_XAML_GENERATED_MAIN, the auto-generated[STAThread]Mainis 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
BuildAndRun.ps1.