简体   繁体   English

Windows 10设备上的System.ExecutionEngineException

[英]System.ExecutionEngineException on Windows 10 device

I am developing a Windows Phone 8.1 app. 我正在开发Windows Phone 8.1应用程序。 It works fine on WP 8 and WP 8.1 devices, but on the device with Windows 10 it throws 它在WP 8和WP 8.1设备上可以正常工作,但在装有Windows 10的设备上会抛出异常

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

in various sections in both "Debug" and "Release" without any data about what went wrong. 在“调试”和“发布”的各个部分中,都没有出现问题的任何数据。 There are some places, where the exception is always thrown and some, where it's thrown from time to time. 在某些地方,总是会引发异常,在某些地方会不时引发异常。 Example code below throws the exception - it is basically a method to switch between tabs, which are StackPanels when the button (Grid with Image) is tapped: 下面的示例代码引发异常-它基本上是在选项卡之间切换的方法,这些选项卡是在点击按钮(带有图像的网格)时使用的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;
    }
}

Finally I managed to fix the code. 最终,我设法修复了代码。 However the error wasn't in the code above. 但是错误不在上面的代码中。 I used something called "Safe Navigation". 我使用了一种叫做“安全导航”的东西。 The example is shown in the code below: 该示例显示在以下代码中:

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

I also handled all asynchronous methods with await operator (I had left some of them before to run asynchronously). 我还使用await运算符处理了所有异步方法(在异步运行之前,我已经离开了其中的一些方法)。 One of those improvements fixed the error. 这些改进之一修复了该错误。

I know this comes over two years beyond the original post, but maybe this will help someone looking for an answer to this question. 我知道这比原始帖子要晚两年,但这也许会帮助某人寻找该问题的答案。 I kept getting apparently random System.ExecutionEngineExceptions from a Window 10 UWP desktop app. 我一直从Window 10 UWP桌面应用程序获得明显的随机System.ExecutionEngineExceptions。 After several days, I found the answer for my particular problem. 几天后,我找到了解决我特定问题的答案。 I had used a MVVM platform, and the x:UID in one of my views had become corrupted. 我使用了MVVM平台,而我的其中一个视图中的x:UID已损坏。

IT SHOULD HAVE BEEN: <TextBlock x:Uid="Battery ... 它应该已经: <TextBlock x:Uid =“ Battery ...

IT WAS: <TextBlock x:Uid="=Battery" 它是: <TextBlock x:Uid =“ =电池”

The error was not flagged as a XAML problem, as many syntax errors similar to this are but once I corrected that error, by removing the unneeded equal sign, the exception went away. 该错误并未标记为XAML问题,因为许多与此类似的语法错误都在其中,但是一旦我纠正了该错误,通过删除了不需要的等号,该异常就消失了。

Hope this helps someone else. 希望这对其他人有帮助。

Clyde 克莱德

Also want to add to the above. 也要添加到上面。 The XAML engine does not check for duplicate x:Uid and I also got this error when I had two x:Uid's with the same name. XAML引擎不检查重复的x:Uid,当我有两个同名的x:Uid时,我也收到此错误。 Made all x:Uid's throughout my project unique (unfortunately expands the resource file) but that resolved any further issues. 使整个项目中的所有x:Uid都唯一(不幸地扩展了资源文件),但这解决了所有其他问题。 Wished that the XAML designer checked for duplicate x:Uid's the was it does for x:Name's. 希望XAML设计器检查是否存在重复的x:Uid,这是对x:Name所做的。

Again, hope it helps someone in the future. 同样,希望它对将来的人有所帮助。

Cheers, 干杯,

Clyde 克莱德

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Windows服务的System.ExecutionEngineException - System.ExecutionEngineException With Windows Service 在Windows Phone 8.1 XAML中获取联系人时发生System.ExecutionEngineException - System.ExecutionEngineException occuring on fetching contacts in windows phone 8.1 xaml 给定System.ExecutionEngineException的GetMessage() - GetMessage() given an System.ExecutionEngineException 抛出System.ExecutionEngineException - System.ExecutionEngineException being thrown DBContext 构造函数中的 System.ExecutionEngineException - System.ExecutionEngineException in DBContext Constructor 仅在调试时才发生System.ExecutionEngineException - System.ExecutionEngineException only when debugging 如何找到 System.ExecutionEngineException 异常的来源 - How to find source of System.ExecutionEngineException Exception 为什么此代码抛出System.ExecutionEngineException - Why this code throws System.ExecutionEngineException 附加到 Revit 过程失败并出现 System.ExecutionEngineException - Attach to Revit process fails with System.ExecutionEngineException OpenTK:GLFW.PollEvents() 处的 System.ExecutionEngineException - OpenTK: System.ExecutionEngineException at GLFW.PollEvents()
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM