The situation
I have made an abstract Page for my UWP app: TestPage. This page contains some abstract items, in this simplified case just a string.
MVCE can be found here
C# code:
public abstract partial class TestPage : Page
{
public abstract string AbstractName { get; }
public TestPage()
{
InitializeComponent();
}
}
XAML:
<Page
x:Class="UWP_Test.TestPage"
...
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<TextBlock HorizontalAlignment="Center"
VerticalAlignment="Center"
Style="{StaticResource TitleTextBlockStyle}"
Text="{x:Bind AbstractName}"/>
</Grid>
</Page>
I then have made two derived pages, or rather classes:
public sealed class TestPage1 : TestPage
{
public override string AbstractName => "TestPage1";
}
public sealed class TestPage2 : TestPage
{
public override string AbstractName => "TestPage2";
}
The problem
If I now try to navigate a Frame to either TestPage1 or TestPage2, this will work in a DEBUG build, but fail in a RELEASE build (System.AccessViolationException: 'Attempted to read or write protected memory.').
This is regardless of whether optimize code or .net native toolchain are enabled or disabled.
For my actual UWP app I would like to be able to use aforementioned principle to quickly make very similar pages that differ in a few aspects such as ItemTemplates, Viewmodels, etc.
I'd appreciate any leads that could either make this work in a release build or how to solve this (without creating a separate XAML file for each derived page, I already use this somewhere else and that is working in release).