Hello!
I created a "Blank App, Packaged (WinUI in Desktop) from VS templates.
In MainPage.xaml I set a name for the root grid.
<Grid x:Name="RootGrid">
</Grid>
Next, in MainPage.xaml.cs, I created a Grid descendant and put it to the Children collection of the RootGrid.
public sealed partial class MainWindow : Window {
public MainWindow() {
this.InitializeComponent();
RootGrid.Children.Add(new MyGrid() { Background = new SolidColorBrush(Colors.Red) });
}
}
public class MyGrid : Grid { }
The main window shows for a seconds and application exits without any errors or exceptions.
Version Info
NuGet package version: Microsoft.WinUI 3.0.0-preview2.200713.0
Windows 10 version: 1903 (OS Build 18362.1082)
@stevenbrix is this another cswinrt issue were we fail when deriving from a winrt type?
Seems another case of this issue.
If I set a descendant of FrameworkElement to custom dependency property, application is crashed too.
public class MyClass : DependencyObject {
public FrameworkElementDescendant MyProperty {
get { return (FrameworkElementDescendant)GetValue(MyPropertyProperty); }
set { SetValue(MyPropertyProperty, value); }
}
public static readonly DependencyProperty MyPropertyProperty =
DependencyProperty.Register("MyProperty", typeof(FrameworkElementDescendant), typeof(MyClass), new PropertyMetadata(null));
}
public class FrameworkElementDescendant : FrameworkElement { }
public MainWindow() {
this.InitializeComponent();
MyClass c = new();
c.MyProperty = new FrameworkElementDescendant();
}
There is a message in output:
The thread 0x79bc has exited with code 0 (0x0).
Unhandled exception at 0x77898DF0 (ntdll.dll) in App29.exe: RangeChecks instrumentation code detected an out of range array access.
The Common Language Runtime cannot stop at this exception. Common causes include: incorrect COM interop marshalling and memory corruption. To investigate further use native-only debugging.
There a good work around for this? Exceedingly difficult to make anything interesting work when I'm constantly hitting this in different scenarios.
Here's a reproduction based on the original posters code
Issue3310.zip
Sorry for the lack of response on this. Thank you all for the details and repro apps.
We don鈥檛 currently have a workaround, I鈥檒l spend some time this morning validating this is fixed with preview3 and respond to this thread.
@PureWeen and @BorzillaR, I just validated that the attached repro app no longer has an issue with preview3
@BorzillaR - I'm closing this out now that preview3 has been released. Please respond if you are still experiencing this issue.
Most helpful comment
@PureWeen and @BorzillaR, I just validated that the attached repro app no longer has an issue with preview3