首页 文章

Windows 10设备上的System.ExecutionEngineException

提问于
浏览
1

我正在开发一个Windows Phone 8.1应用程序 . 它在WP 8和WP 8.1设备上运行良好,但在Windows 10的设备上它会抛出

ExecutionEngineException was unhandled. An unhandled exception of type 'System.ExecutionEngineException' occurred in Unknown Module.

在“调试”和“发布”的各个部分中没有任何关于出错的数据 . 有些地方总是抛出异常,有些地方不时会抛出异常 . 下面的示例代码抛出了异常 - 它基本上是一个在标签之间切换的方法,当点击按钮(Grid with Image)时,它们是StackPanels:

private void Grid_Tapped(object sender, TappedRoutedEventArgs e)
{
    if(!isMapVisible)
    {
        hideSection();
        map_wrapper.Visibility = Windows.UI.Xaml.Visibility.Visible;
        map_button.Background = new SolidColorBrush(ColorHelper.FromArgb(0xFF, 40, 110, 73));
        map_icon.Source = new BitmapImage(new Uri(FileHelper.getIconPath("tu_2.png")));
        isMapVisible = true;
    }
}

private void hideSection()
{
    if(isMapVisible)
    {
        map_button.Background = new SolidColorBrush(ColorHelper.FromArgb(0xFF, 238, 238, 238));
        map_icon.Source = new BitmapImage(new Uri(FileHelper.getIconPath("tu.png")));
        isMapVisible = false;
        map_wrapper.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
    }
    else if(isPhotoVisible)
    {
        photo_button.Background = new SolidColorBrush(ColorHelper.FromArgb(0xFF, 238, 238, 238));
        photo_icon.Source = new BitmapImage(new Uri(FileHelper.getIconPath("photo_green.png")));
        isPhotoVisible = false;
        image_wrapper.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
    }
    else if(isListVisible)
    {
        list_button.Background = new SolidColorBrush(ColorHelper.FromArgb(0xFF, 238, 238, 238));
        list_icon.Source = new BitmapImage(new Uri(FileHelper.getIconPath("!2.png")));
        isListVisible = false;
        news_wrapper.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
    }
}

3 回答

  • 0

    最后我设法修复了代码 . 但是错误不在上面的代码中 . 我使用了一种叫做“安全导航”的东西 . 示例显示在下面的代码中:

    Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
    {
        rootFrame.Navigate(typeof(MainPage));
    });
    

    我还使用 await 运算符处理了所有异步方法(我之前离开了一些异步方法以异步运行) . 其中一项改进修复了错误 .

  • 0

    我知道这比原来的帖子还要早两年,但也许这会帮助那些寻找这个问题答案的人 . 我一直从Window 10 UWP桌面应用程序中获得明显随机的System.ExecutionEngineExceptions . 几天后,我找到了我特定问题的答案 . 我使用过一个MVVM平台,我的一个视图中的x:UID已经损坏了 .

    IT SHOULD HAVE BEEN: <TextBlock x:Uid =“电池......

    IT WAS: <TextBlock x:Uid = "=Battery"

    该错误未被标记为XAML问题,因为许多类似于此的语法错误,但是一旦我纠正了该错误,通过删除不需要的等号,该异常就消失了 .

    希望这有助于其他人 .

    克莱德

  • 2

    也想添加到上面 . XAML引擎不会检查重复的x:Uid,当我有两个x:同名的Uid时,我也遇到了这个错误 . 所有x:Uid都在我的项目中独一无二(不幸的是扩展了资源文件),但这解决了任何进一步的问题 . 希望XAML设计师检查重复的x:Uid是否适用于x:Name的 .

    再次,希望它能帮助将来的某个人 .

    干杯,

    克莱德

相关问题