CsWinRT
CsWinRT copied to clipboard
COMException in IVectorMethods`1.Append
In production, reported via AppCenter, I get a COMException with HRESULT E_FAIL in a method creating a MenuFlyout. I have pasted a shortened version below:
private MenuFlyout CreateZoneContextMenu(Zone zone)
{
var cmenu = new MenuFlyout();
var mpaste = new MenuFlyoutItem() { Text = "Paste" };
cmenu.Items.Add(mpaste);
cmenu.Items.Add(new MenuFlyoutSeparator());
var m3 = new MenuFlyoutItem() { Text = "Combine" };
cmenu.Items.Add(m3);
return cmenu;
}
The exception stack is:
System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.
at WinRT.DelegateExtensions.DynamicInvokeAbi(Delegate del, Object[] invoke_params)
at ABI.System.Collections.Generic.IVectorMethods`1.Append(IObjectReference obj, T value)
at MyApp.CreateZoneContextMenu(Zone zone)
This occured on Windows 10.0.19044, I do not know if other versions are also effected.
This works fine on my PC, I have never reproduced it and honestly don't even know where I would start reproducing this. And it works also for the majority of users and invocations.
The only reason I could image for an Append to a Vector to fail, is maybe an out of memory situation? Does that sound plausible to you?
Expected behavior
I don't expect a C# call to an .Add( method to throw an exception.
Version Info
Windows App SDK / WinUI 3.0 (packaged) 1.0.3
Original AppCenter Crash report (click to expand)
OS: WINDOWS
Windows: 10.0.19044
Date: 2022-05-19T12:00:42.0898593Z
Exception Stack:
System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.
at WinRT.DelegateExtensions.DynamicInvokeAbi(Delegate del, Object[] invoke_params)
at ABI.System.Collections.Generic.IVectorMethods`1.Append(IObjectReference obj, T value)
at Telani.Modern.View.ZoneRenderer.CreateZoneContextMenu(Zone zone, ZoneArea zonearea)
at Telani.Modern.View.ZoneRenderer.PaintZone(Zone zone, Panel container)
at Telani.Modern.View.ZoneRenderer.RepaintZones()
at Telani.Modern.View.DrawingCanvas.Poly_PreviewMouseUp(Object sender, PointerRoutedEventArgs e)
at ABI.Microsoft.UI.Xaml.Input.PointerEventHandler.Do_Abi_Invoke(IntPtr thisPtr, IntPtr sender, IntPtr e)
at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|20_0(Int32 hr)
at ABI.Windows.ApplicationModel.Core.IUnhandledErrorMethods.Propagate(IObjectReference _obj)
at Windows.ApplicationModel.Core.UnhandledError.Propagate()
at Microsoft.AppCenter.Utils.ApplicationLifecycleHelperWinUI.<.ctor>b__1_1(Object sender, UnhandledErrorDetectedEventArgs eventArgs)