2

我的 windows phone 8 应用程序遇到了一个非常奇怪的问题。

在我开始调试后,模拟器来了,我的应用程序被部署并开始运行。

我通过 app.xaml 进行了调试,然后调试器甚至点击了“Mainpage.xaml”的构造函数。

从构造函数中按 F5 后,模拟器一直显示“正在加载”屏幕,并且从未真正显示 mainpage.xaml UI。

在此处输入图像描述

这是“调试”的输出

'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: DefaultDomain): Loaded
'C:\windows\system32\mscorlib.ni.dll'. Skipped loading symbols. Module is optimized and the 
debugger option 'Just My Code' is enabled.
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 
'C:\windows\system32\System.Windows.RuntimeHost.ni.dll'. Skipped loading symbols. Module is   
optimized and the debugger option 'Just My Code' is enabled.
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 
'C:\windows\system32\System.Windows.ni.dll'. Skipped loading symbols. Module is optimized and the 
debugger option 'Just My Code' is enabled.
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 
'C:\windows\system32\System.Net.ni.dll'. Skipped loading symbols. Module is optimized and the 
debugger option 'Just My Code' is enabled.
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 
'C:\windows\system32\System.ni.dll'. Skipped loading symbols. Module is optimized and the 
debugger option 'Just My Code' is enabled.
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded  
'C:\windows\system32\System.Xml.ni.dll'. Skipped loading symbols. Module is optimized and the 
debugger option 'Just My Code' is enabled.
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 
'C:\Data\Programs\{CBED48CE-DB64-44F3-9F60-7BCFF4093AAB}\Install\Tee.DLL'. Symbols loaded.
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded  
'C:\windows\system32\System.Data.Linq.ni.dll'. Skipped loading symbols. Module is optimized and 
the debugger option 'Just My Code' is enabled.
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 
'C:\windows\system32\Microsoft.Phone.ni.dll'. Skipped loading symbols. Module is optimized and 
the debugger option 'Just My Code' is enabled.
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 
'C:\windows\system32\Microsoft.Phone.Interop.ni.dll'. Skipped loading symbols. Module is 
optimized and the debugger option 'Just My Code' is enabled.
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 
'C:\windows\system32\Microsoft.Phone.Data.Internal.ni.dll'. Skipped loading symbols. Module is 
optimized and the debugger option 'Just My Code' is enabled.
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 
'C:\windows\system32\System.Core.ni.dll'. Skipped loading symbols. Module is optimized and the 
debugger option 'Just My Code' is enabled.
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded   
'C:\windows\system32\System.Xml.Serialization.ni.dll'. Skipped loading symbols. Module is 
optimized 
and the debugger option 'Just My Code' is enabled.
The thread 0x8f4 has exited with code 259 (0x103).
The thread 0x8fc has exited with code 259 (0x103).
The thread 0x988 has exited with code 259 (0x103).
The thread 0x998 has exited with code 259 (0x103).
The thread 0x9a0 has exited with code 259 (0x103).

启动对象正确设置为“app”,并且在清单中导航页面设置为“mainpage.xaml”,这就是调试器确实命中“Mainpage.xaml”构造函数的原因。

可能是什么问题?

4

1 回答 1

2

哦....原来我在完成后对我的应用程序代码运行了 VS 2012 代码分析,它在“CompleteInitializePhoneApplication”方法中添加了一个空检查,导致了这个错误。

在 App.xaml 中,它应该是

        // Do not add any additional code to this method
    private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e)
    {
        // Set the root visual to allow the application to render
        if (RootVisual != RootFrame)
            RootVisual = RootFrame;

        // Remove this handler since it is no longer needed
        RootFrame.Navigated -= CompleteInitializePhoneApplication;
    } 

但是无论是 Resharper 还是代码分析都向它添加了这个愚蠢的空检查,它变成了这样:

        // Do not add any additional code to this method
    private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e)
    {
        // Set the root visual to allow the application to render
        if (RootVisual != null && RootVisual != RootFrame)
            RootVisual = RootFrame;

        // Remove this handler since it is no longer needed
        RootFrame.Navigated -= CompleteInitializePhoneApplication;
    }

所以基本上我的 RootVisual 从来没有开始。

感谢@ErnodeWeerd 提出从头开始的建议。

于 2013-06-15T06:55:49.763 回答