maui-samples icon indicating copy to clipboard operation
maui-samples copied to clipboard

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

Open deepathiruppathy01 opened this issue 1 year ago • 0 comments

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

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?

deepathiruppathy01 avatar Aug 20 '24 09:08 deepathiruppathy01