【发布时间】:2016-01-05 10:04:10
【问题描述】:
调试版本(86、64、ARM)一切正常,发布版本构建正常,但是当它们运行时,我的应用程序窗口打开并保持空白(白色背景)。我在输出中看到的唯一错误是一大堆:
...PDB file was not present when IL code was compiled to native.
我不确定丢失的 .pdb 文件是否是罪魁祸首 - 很确定它们不是,因为它们只是用于调试目的,对吗? 无论如何,这是我尝试为 Windows 应用商店准备的第一个 UWP 应用程序,但我不确定是否需要做一些特别的事情,比如在我自己的计算机上对其进行签名以测试发布版本?
编辑 1:感谢 @Alan 的建议,手动卸载应用程序有时会让我通过空白窗口加载应用程序栏,但是当它没有挂在启动屏幕上时,我会收到这些错误:
Debugger Error 1, Debugger Error 2
我没有对初始屏幕做任何特别的事情,使用清单中的内置工具加载我的所有视觉资产,并且没有修改 App.xaml.cs 的默认值。这是我的 Mainpage.cs:
using Sublist.Classes;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
namespace Sublist
{
public sealed partial class MainPage : Page
{
const string TAG = "MainPage: ";
// for loading and saving user data and settings
public static DataHandler dataHandler;
public static MasterList<Entry> masterList;
//public static int listViewSelectedIndex = -1;
public MainPage()
{
this.InitializeComponent();
dataHandler = new DataHandler(this);
masterList = new MasterList<Entry>();
// load user data
if (dataHandler.userDataList != null)
masterList = dataHandler.userDataList;
masterList.UpdateListView(this);
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
dataHandler.LoadUserSettings();
}
private void AppBarAdd_Click(object sender, RoutedEventArgs e)
{
masterList.AddRow(this);
}
private void AppBarRemove_Click(object sender, RoutedEventArgs e)
{
if (!(mainListView.SelectedIndex < 0))
{
masterList.RemoveRow(this);
}
}
private void AppBarMoveDown_Click(object sender, RoutedEventArgs e)
{
}
private void AppBarMoveUp_Click(object sender, RoutedEventArgs e)
{
}
private void AppBarIndent_Click(object sender, RoutedEventArgs e)
{
// indent the row control if currently selected index is a list view item
if (-1 < mainListView.SelectedIndex && mainListView.SelectedIndex < mainListView.Items.Count)
{
// but don't allow more than one indent past above row's indent level
RowControl rc = (RowControl)mainListView.Items[mainListView.SelectedIndex];
int indexMinus1 = mainListView.SelectedIndex - 1;
if (-1 < indexMinus1 && rc.indentProp <= masterList[indexMinus1].indent)
{
rc.indentProp++;
}
}
// then update list view
masterList.UpdateListView(this);
}
private void AppBarUnindent_Click(object sender, RoutedEventArgs e)
{
// unindent the row control if currently selected index is a list view item
if (-1 < mainListView.SelectedIndex && mainListView.SelectedIndex < mainListView.Items.Count)
{
// but don't allow unindenting off left side of page
RowControl rc = (RowControl)mainListView.Items[mainListView.SelectedIndex];
if (rc.indentProp > 0)
{
rc.indentProp--;
}
}
// then update list view
masterList.UpdateListView(this);
}
public void AppBarShowCompl_Click(object sender, RoutedEventArgs e)
{
dataHandler.SaveUserSettings();
masterList.UpdateListView(this);
}
public void AppBarMarkAsCompleted_Click(object sender, RoutedEventArgs e)
{
// toggle hidden state of active entry
if (-1 < mainListView.SelectedIndex && mainListView.SelectedIndex < masterList.Count)
{
masterList[mainListView.SelectedIndex].completed = (masterList[mainListView.SelectedIndex].completed) ? false : true;
masterList.UpdateListView(this);
}
}
}
}
我已将开源 Template10 中的 FileService 和 SettingsService 类添加到项目中。
构建设置“使用 .NET Native 工具链编译”未选中,我尝试在调试/发布版本中都选中/未选中进行部署,现在调试版本也经常挂在启动画面上?检查后,我也会收到一大堆这些错误:
'Sublist.exe' (Win32): Loaded 'C:\Windows\System32\biwinrt.dll'. Skipped loading symbols. Module is native, and native debugging is currently disabled.
我尝试下载服务器符号但没有成功...
【问题讨论】:
-
我在发布模式下尝试了很多微软官方示例和我自己的项目,但没有遇到这个问题。尝试先手动卸载应用程序,然后再次部署发布模式构建。为了缩小问题范围,看看如果取消选中项目属性页的 Build 选项卡上的“Compile with .Net Native tool chain”会发生什么。以及有关使用了什么(第三方/开源)的更多详细信息,以及您对启动画面、起始页或 App.xaml.cs 中的某些内容所做的任何特殊操作,可能有助于其他人理解。
-
尝试找出挂起(或未处理的异常)发生的位置。如果您在 app.xaml.cs 中没有做任何特别的事情,请尝试注释掉 this.InitializeComponent(); 期望的所有代码;看看会发生什么。要获取调试版本的更多调试信息,请在项目属性页面的调试选项卡中将调试器类型更改为混合。您将能够在 Visual Studio 输出窗口中获得 COM 错误代码。您可以通过查看第一个屏幕截图中“e”的内容来检查堆栈跟踪。
-
我的意思是注释掉主页构造函数中的代码。它们的全部或部分以确定哪个部分会导致问题。我想这个问题应该与 DataHandler 和 MasterList 有关。如果是这种情况,您无法弄清楚问题所在。尝试简化实现并提供可用于其他人重现问题的代码。
-
经过更多故障排除后确定,似乎问题出在使用.NET Native工具链编译。这究竟是什么意思?我不明白这样做(发布版)和不这样做(调试版)之间的区别?
-
这里是 github 上 Sublist 的链接:github.com/toadlyBroodle/Sublist
标签: c# windows-10