dotnet / dotnet/maui-samples

Application Crash When Using MediaPicker in Native Embedding Demo on Windows (WinUI Project)

Open
#501 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
3.7k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

We are experiencing an issue where the application crashes when trying to browse an image file using the MediaPicker class in a WinUI project within the Native Embedding Demo. The problem occurs specifically when attempting to execute MediaPicker.Default.PickPhotoAsync().

**Details:**
* Sample Reference: We referenced the sample from the following GitHub location:
https://github.com/dotnet/maui-samples/tree/main/8.0/PlatformIntegration/NativeEmbeddingDemo
* Modifications: In the MyMauiContent.xaml file, we modified the default button named "CounterBtn" and changed its Clicked event to execute the method MediaPicker.Default.PickPhotoAsync().
* Modified Sample Link: [BrowseImagesUsingNativeEmbeddingDemo.zip](https://github.com/user-attachments/files/16673540/BrowseImagesUsingNativeEmbeddingDemo.zip)

**Replication Steps:**
a. Open the solution file in Visual Studio and set the "NativeEmbeddingDemo.WinUI" project as the startup project.
b. Run the sample and click on the "Browse image" button.
c. The application crashes.

**Issue:** The crash appears to be due to the following error:
"The active Window cannot be detected. Ensure that you have called Init in your Application class."

Could you please share your suggestions on how to resolve this issue?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.