C# 尝试启动UWP程序时System.AccessViolationException异常
我尝试制作一个新的UWP应用程序只是为了测试一下,但现在我遇到了一个例外:C# 尝试启动UWP程序时System.AccessViolationException异常,c#,xaml,uwp,C#,Xaml,Uwp,我尝试制作一个新的UWP应用程序只是为了测试一下,但现在我遇到了一个例外: System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.' 在制定新的解决方案后,我所做的只是多制作一些页面,并将其添加到App()中,以实现全局后退按钮: public App() {
System.AccessViolationException: 'Attempted to read or write protected memory.
This is often an indication that other memory is corrupt.'
在制定新的解决方案后,我所做的只是多制作一些页面,并将其添加到App()中,以实现全局后退按钮:
public App()
{
this.InitializeComponent();
this.Suspending += OnSuspending;
var currentView = SystemNavigationManager.GetForCurrentView();
currentView.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
Frame rootFrame = Window.Current.Content as Frame;
}
private void App_BackRequested(object sender, Windows.UI.Core.BackRequestedEventArgs e)
{
e.Handled = On_BackRequested();
}
现在,每一次都是这样:
var currentView = SystemNavigationManager.GetForCurrentView();
我得到这个例外。我的点子快用完了。有人知道这是什么原因吗?在我的调试设置中,我取消了“在模块加载时抑制JIT优化”设置,正如其他地方所建议的那样,但这没有帮助
在制作UWP应用程序时,有什么我不了解的地方吗?你可以点击顶部的按钮,然后页面会在它们下面改变。这是背后的XAML:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="2*"/>
<RowDefinition Height="10*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" x:Name="stackPanel_up" Orientation="Horizontal" HorizontalAlignment="Center"
VerticalAlignment="Center" Margin="10">
<Button x:Name="eka" Background="Aqua" Content="First" Width="200"
Height="50" FontSize="30" FontWeight="Bold" CornerRadius="10" Margin="5,0,5,0"
Click="eka_Click"/>
<Button x:Name="toka" Background="Aqua" Content="Second" Width="200" Height="50"
FontSize="30" FontWeight="Bold" CornerRadius="10" Margin="5,0,5,0"
Click="toka_Click"/>
<Button x:Name="kolmas" Background="Aqua" Content="Third" Width="200" Height="50"
FontSize="30" FontWeight="Bold" CornerRadius="10" Margin="5,0,5,0"
Click="kolmas_Click"/>
</StackPanel>
<Button Grid.Column="0" Grid.Row="0" x:Name="BackBtn" FontSize="50" Margin="40,0,0,0"
HorizontalAlignment="Left" Width="100" Height="100" CornerRadius="30"
Background="Transparent" Click="Back_Click" Style="{StaticResource NavigationBackButtonNormalStyle}" />
<Frame Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" x:Name="ChangingArea" Margin="10" Background="AliceBlue"></Frame>
</Grid>
Hello,您可以尝试移动
var currentView=SystemNavigationManager.GetForCurrentView()
到主页,即在MainPage.on导航到事件中处理AppViewBackButton
。