Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running unpackaged Windows app as admin prevents FilePicker from working #20830

Closed
beeradmoore opened this issue Feb 25, 2024 · 3 comments
Closed
Labels
area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info platform/windows 🪟 t/bug Something isn't working
Milestone

Comments

@beeradmoore
Copy link
Contributor

Description

Not sure why, but FilePicker throws an exception when trying to use it in an application running as admin. Unsure what else could be broken. Should test suite be re-run as admin as well as standard user?

Exception message is an empty string and the stacktrace only shows my code. Unsure if this is a result of debugging as admin, or if that is the exception that it threw.

Excpetion itself is of type System.Runtime.InteropServices.COMException.

Discovery story:
Created an installer with NSIS for distribting dev tool internally. After sending out first builds I was getting reports that tool does not work on first launch. My installer has a "launch now" at the end of the installer and because the installer runs as admin so does the launched process. Closing and re-opening my application works as expected.

Steps to Reproduce

From scratch:

  1. Launch VS as standard user and create MAUI project
  2. Convet to unpackged app (add <WindowsPackageType>None</WindowsPackageType> to csproj, and change launchSettings.json to use Project for commandName)
  3. Add file picker code
  4. See that the code works
  5. Close VS
  6. Launch VS as admin (the following steps can also be reproduced by launching a built exe as admin)
  7. Try use file picker

From provided repro:

  1. Launch VS as standard user and open FilePickerAsAdmin.sln
  2. Debug the program and press the Browse for file button. This should present a picker and allows you to pick a file. It does nothing with this file, just displays an alert that you were able to pick a file.
  3. Close VS
  4. Launch VS as admin (the following steps can also be reproduced by launching a built exe as admin)
  5. Try press the Browse for file button again
  6. Error message with nothing helpful should be displayed.

Link to public reproduction project repository

https://github.com/beeradmoore/maui-issue-FilePickerAsAdmin

Version with bug

8.0.7 SR2

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

Windows 11 23H2

Did you find any workaround?

No

Relevant log output

No response

@beeradmoore beeradmoore added the t/bug Something isn't working label Feb 25, 2024
@jsuarezruiz jsuarezruiz added platform/windows 🪟 area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info labels Feb 26, 2024
@jsuarezruiz jsuarezruiz added this to the Backlog milestone Feb 26, 2024
@ghost
Copy link

ghost commented Feb 26, 2024

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

@drasticactions
Copy link
Contributor

This is a WinUI3 bug, microsoft/WindowsAppSDK#2504. The APIs invoked by MAUI in essentials are the same you would use when building a straight WinUI 3 app, and building a file picker there and running it as admin will cause the same exception. Fixing the linked bug should fix this issue. Sorry.

@drasticactions drasticactions closed this as not planned Won't fix, can't repro, duplicate, stale Feb 27, 2024
@beeradmoore
Copy link
Contributor Author

I have a WinUI3 (non-MAUI) app that I've had users run as admin and not had a problem so I didn't even think of a WinUI3 issue. Turns out it's because open file dialog is only in un-released dev build that would have been an issue come next update. Tested it as admin and got the same result as above.

Thanks for the thread link, looks like there are some workarounds in there I'll dig into for both my MAUI and WinUI3 projects.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info platform/windows 🪟 t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants