CommunityToolkit / Microsoft.Toolkit.Win32

ARCHIVE - This repository contained XAML Islands wrapper controls and tooling for XAML Islands with WinUI 2, see readme for more info about XAML Islands with WinUI 3 and the WindowsAppSDK.
https://aka.ms/windowsappsdk
Other
383 stars 89 forks source link

Can't catch exception in custom UWP control #281

Open nxtn opened 4 years ago

nxtn commented 4 years ago

Describe the bug

An exception was thrown in a UWP code path and crashed the application but I couldn't catch it with try-catch or AppDomain.UnhandledException and it didn't trigger a breakpoint in Visual Studio.

Steps to Reproduce

DataGrid is apparently not a simple control, but I can't narrow down the issue yet.

Steps to reproduce the behavior:

  1. Follow Host a custom UWP control in a WPF app using XAML Islands to create a WPF app that targets .NET Core 3.1.
  2. ~In the UWP control project, add a package reference to Microsoft.Toolkit.Uwp.UI.Controls.DataGrid, version 7.0.0-preview2.~
  3. Add codes in MyUserControl.xaml.
    xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
    <controls:DataGrid/>
  4. ~(Can't reproduce now.) "Start debugging" with Visual Studio. The app crashes. Output from "Debug":~
    The target process exited without raising a CoreCLR started event. Ensure that the target process is configured to use .NET Core. This may be expected if the target process did not run on .NET Core.
    The program '[1448] Wpf.exe' has exited with code -2147450740 (0x8000808c).
  5. Remove the package reference to Microsoft.Toolkit.Uwp.UI.Controls.DataGrid. Clone WindowsCommunityToolkit and add a project reference to Microsoft.Toolkit.Uwp.UI.Controls.DataGrid.csproj.
  6. "Start debugging" with Visual Studio. The app crashes when executing DependencyObject.GetValue. Output from "Debug":
    Exception thrown: 'System.AggregateException' in System.Private.CoreLib.dll
    The program '[8748] Wpf.exe' has exited with code -1073741189 (0xc000027b).

Expected behavior

I can tell what went wrong by inspecting the exception details.

Screenshots

Not applicable.

Environment

NuGet Package(s): 
-and-
Package Version(s): 
Microsoft.Toolkit.Wpf.UI.XamlHost 6.1.1
Microsoft.NETCore.UniversalWindowsPlatform 6.2.10
Microsoft.Toolkit.Win32.UI.XamlApplication 6.1.1

Project .NET Version:
- [ ] .NET Framework (version: )
- [ ] .NET Core 3
- [x] .NET Core 3.1 (SDK: 5.0.1-preview.6, runtime: 3.1.6)

Windows 10 Build Number:
- [ ] Fall Creators Update (16299)
- [ ] April 2018 Update (17134)
- [ ] October 2018 Update (17763)
- [ ] May 2019 Update (18362)
- [x] Version 2004 (19041)
- [ ] Insider Build (build number: )

App min and target version:
- [ ] Fall Creators Update (16299)
- [ ] April 2018 Update (17134)
- [ ] October 2018 Update (17763)
- [x] May 2019 Update (18362)
- [ ] Insider Build (xxxxx)

Device form factor:
- [x] Desktop
- [ ] Xbox
- [ ] Surface Hub
- [ ] IoT

Visual Studio 
- [ ] 2017 (version: )
- [ ] 2019 (version: ) 
- [x] 2019 Preview (Version 16.8.0 Preview 1.0)

Additional context

None.

I also got other exceptions like FileNotFoundException which couldn't be caught.

ghost commented 4 years ago

Hello NextTurn, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌

marb2000 commented 4 years ago

@ocalvo @Austin-Lamb any insights that can help @NextTurn ?

stevenbrix commented 3 years ago

@NextTurn do you have native debugging enabled?

nxtn commented 3 years ago

do you have native debugging enabled?

Probably not. I'll try it next time I restore the build environment. Is it a known solution?