Open FreddyDgh opened 3 years ago
Can anyone confirm that this is the correct repo for this issue? I am sure that people are busy due to the upcoming .NET 5 release, but I noticed that the issue has not even been given a bug label yet.
My original reasoning for posting in this repo was because the underlying Windows Clipboard API obviously works with partial trust (e.g. from UWP apps), and because the same exact .NET 5 code works when in full trust but not in partial trust when using the CsWinRT projections, it seemed likely that the issue would have to be fixed at the CsWinRT level. Perhaps that is not the case?
I am wondering if it might be better to open an issue on the Project Reunion repo, but I was hoping somebody might confirm what is actually the best repo before opening more issues elsewhere.
@FreddyD-GH thanks for your patience. This repo is probably as good as any, since the issue intersects several Project Reunion technologies. We'll try to triage soon, but it may take a few days.
@FreddyD-GH - the dev team is looking into this but they want to confirm exactly how you set Partial Trust for your package. Do you have a pointer to a github repo or can you include your package.appxmanifest?
I appreciate you taking a look at this.
I just change the setting to partial trust using the Visual Studio 2019 Properties Window. This does not modify the template version of the package.appxmanifest file, but instead adds the line <TrustLevel>Partial</TrustLevel>
to the <ProjectReference>
node in the *.wapproj file. If I recall correctly, this does generate a slightly different output package.appxmanifest when building, because the template values are overwritten differently based on whether it's full trust or partial trust.
I setup a repo you can look at: https://github.com/FreddyD-GH/TempClipboardPartialTrust
@AdamBraden @Scottj1s were you able to look into this issue at all? I just found out that I can successfully use the Clipboard API if I copy text from certain search boxes contained in built-in Windows apps. For example, I can copy successfully from the Windows search box (keyboard shortcut: WIN + S), the File Explorer search box, and the Photos app search box. However, other apps that I've tried copying from (Visual Studio, MS Edge, notepad, etc.) all give the threading error. I am starting to think the issue is probably not about CsWinRT per se, but maybe more about the details of how Windows handles "AppContainer" apps, and perhaps this issue is better suited for the Project Reunion repo.
fyi the apps where this works are likely using the WinRT clipboard APIs whereas the others are just using the OLE clipboard
may be fixed with microsoft/CsWinRT#612
This is a limitation of the underlying api and has nothing to do with cswinrt.
Moving to Project Reunion as the appropriate backlog.
Description
When trying to get data from the clipboard, the following exception is thrown:
The issue only occurs when the application is packaged and running in partial trust. No exception is thrown when unpackaged or when packaged running in full trust.
Environment Information
.NET SDK version: 5.0.100-rc.1.20452.10 VS Version: Version 16.8.0 Preview 3.1
Repro Steps
7b. Workaround: Currently, it looks like the packaging project doesn't automatically copy the needed dependencies when targeting 'net5.0-windows10.0.18362.0'. After building the packaging project, manually copyWinRT.Runtime.dll
andMicrosoft.Windows.SDK.NET.dll
to thebin\AnyCPU\Debug\AppX\[AppName]
folder. Omitting this workaround was giving the following message when trying to debug the packaged app:Edit: packaging project now seems to copy dependencies correctly, so workaround in step 7 should no longer be needed (tested using .NET 5 RC2/Visual Studio 16.8.0 Preview 4)