When I run the app as Administrator the MediaPicker.Default.CapturePhotoAsync method works
Maui MediaPicker.Default.CapturePhotoAsync windows doesn't display camera
When I run the app is the VS 2022 on Windows 10 the MediaPicker.Default.CapturePhotoAsync method displays the camera and allows me to capture a photo.
When the app is published and installed on Windows 10 the MediaPicker.Default.CapturePhotoAsync method doesn't display the camera and sends me a bogus image filename.
I have a looked for a permission setting but it doesn't seem to be a requirement for Windows apps.
The MediaPicker.Default.CapturePhotoAsync method also works great in iOS and Android.
How can I get the MediaPicker.Default.CapturePhotoAsync method to work on a published Windows app
Windows 10
.NET MAUI
-
Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 32,546 Reputation points • Microsoft Vendor
2024-05-01T01:36:41.6266667+00:00 Glad you solved the problem. I converted your comment to an answer, thanks for your sharing.
-
Grant Schaffer 25 Reputation points
2024-05-06T15:51:48.4533333+00:00 Hi Wenyan,
Any idea of how to make this work as when NOT running as administrator?
Thanks,
Grant
-
Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 32,546 Reputation points • Microsoft Vendor
2024-05-07T06:20:59.83+00:00 You published the app according to the following doc- Publish a .NET MAUI app to a folder for Windows - .NET MAUI | Microsoft Learn, and installed the MSIX, right? I tried to publish an app with media picker feature, but I cannot reproduce your issue.
-
Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 32,546 Reputation points • Microsoft Vendor
2024-05-15T02:44:48.3166667+00:00 May I know whether your issue has been solved or not? If you're still having problems, please explain in detail what is still going wrong and what you need help with.
-
Grant Schaffer 25 Reputation points
2024-05-15T17:32:52.2333333+00:00 While the camera works fine when running as administrator I do not want to have to instruct all of the apps users to have do that as well.
So how can I get it work without running as administrator?
Thank you
-
Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 32,546 Reputation points • Microsoft Vendor
2024-05-16T09:28:02.2833333+00:00 Do you publish the app as a MSIX and deploy it?
-
Felipe Pineda O-I 10 Reputation points
2024-05-17T13:51:44.6266667+00:00 Yeah, I did some test with the camera on my personal laptop that is not in a domain and the account is the administrator and it works. But in my work laptop that is in a domain the only way that the camera is works is by running the app as Administrator. Please help with this.
-
Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 32,546 Reputation points • Microsoft Vendor
2024-05-21T08:12:16.8966667+00:00 I tested but cannot reproduced your issue. Please check if there are any permission settings on your machine.
-
HASSALL Michael 0 Reputation points
2024-05-22T00:26:56.3166667+00:00 Did you get this working when you are not administrator?
We are getting the following error on Windows only:
FileNotFoundException: 'Unable to find the specified file'
It used to work until about a month ago (before we updated our libraries).
We can't get it running as admin either. Tried Personal and work laptops.
Source is "Microsoft.Maui.Essentials"
Stack trace isn't very helpful.
Microsoft.Maui.Media.MediaPickerImplementation.WinUICameraCaptureUI.d__10.MoveNext(). -
Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 32,546 Reputation points • Microsoft Vendor
2024-05-31T05:44:51.6+00:00 Hi @HASSALL Michael , please create a new thread to post your issue. And you can attach the link here so that we can work together to figure it out.
-
Grant Schaffer 25 Reputation points
2024-06-21T15:56:05.5066667+00:00 Hey Wenyan,
Now iOS is not capturing images as well.
The call to 'await MediaPicker.Default.CapturePhotoAsync()' brings up the camera, takes a picture, the user presses use photo and then Maui function stops running.
Any suggestions for this?
Tested on iOS 15.8.2 and 16.3.1.
-
Grant Schaffer 25 Reputation points
2024-06-23T19:43:17.3666667+00:00 Yes I published the app as a MSIX and deploy it.
What are the next steps to resolve this?
Thank you
-
Grant Schaffer 25 Reputation points
2024-06-27T17:54:54.4033333+00:00 Has anyone in this thread gotten this so work without being administrator?
I now cannot get the MediaPicker.PickPhotoAsync function to work while running under the administrator account?
So either I can take picker or pick photo but not both?
-
HASSALL Michael 0 Reputation points
2024-06-30T22:33:37.1433333+00:00 We are trying to resolve this still as our userbase cannot run as admin in our corporate environment.
I made a new version of my app and pulled all the code across except for the sln and proj files. Then Media Picker worked in windows again when building from VS Pro. One of my team pulled the new code and it wouldn't work after he built using VS Code. We are curious if there is a connection with building using VS Code and are investigating.
If it continues to be an issue we will likely write our own Media Picker which has been a suggestion elsewhere.
https://github.com/dotnet/maui/issues/7660#issuecomment-1152347557 -
Felipe Pineda O-I 10 Reputation points
2024-07-01T06:12:20.49+00:00 Reputation points
Jul 1, 2024, 8:11 AM
Just to clarify, if you run the application in Visual Studio Pro and debug the camera opens well. But on the same computer when I install the application it does not work because my account doesn't have admin rights, so it is impossible to debug the problem. Also, I put some flags in the code and when I open the camera it does not throw errors but the camera does not open.
Please help with this is very sad that the nuget designed by Microsoft doese not work with Microsoft OS
For now I installed the CameraMaui nuget and this nuget is working with out admin permissions. Please help
-
Grant Schaffer 25 Reputation points
2024-07-01T17:28:18.9733333+00:00 I can confirm Felipe's post as well as please help.
-
Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 32,546 Reputation points • Microsoft Vendor
2024-07-02T09:00:39.9533333+00:00 Hi @Grant Schaffer For your issue about iOS, please create a new thread and attach the thread link here so that we can work together to figure it out.
For your Windows issue that require running applications as an Administrator, could you provide the following information?
- What's the detailed MAUI version?
- What's the Windows version?
- I called the
MediaPicker.Default.CapturePhotoAsync()
method in an empty MAUI project (and publish as MSIX), but I still cannot reproduce the issue. Would you mind share a minimal reproduceable sample with me? Please make sure there is not sensitive private information.
(Important: Maui was updated to launch the Windows Camera app itself instead of using CameraCaptureUI, please see Use the launcher to start the Windows camera by mattleibow · Pull Request #13220 · dotnet/maui (github.com))
Sign in to comment
1 answer
Sort by: Most helpful
-
Grant Schaffer 25 Reputation points
2024-04-30T16:26:22.0733333+00:00 -
Felipe Pineda O-I 10 Reputation points
2024-07-01T06:11:01.4566667+00:00 Just to clarify, if you run the application in Visual Studio Pro and debug the camera opens well. But on the same computer when I install the application it does not work because my account doesn't have admin rights, so it is impossible to debug the problem. Also, I put some flags in the code and when I open the camera it does not throw errors but the camera does not open.
Please help with this is very sad that the nuget designed by Microsoft doese not work with Microsoft OS
For now I installed the CameraMaui nuget and this nuget is working with out admin permissions. Please help
-
Grant Schaffer 25 Reputation points
2024-07-01T17:29:13.8+00:00 I can confirm Felipe post and as well as please help.
Sign in to comment -