我们有一个基于导航的WPF应用程序。 直接从Visual Studio运行时,它工作正常, 或者甚至将文件复制到另一个目录或另一台计算机并在那里运行。
我们使用ClickOnce和大多数人在互联网上部署应用程序 这不会导致任何问题。
然而,它偶尔会完全冻结而你会得到 经典的“应用程序xxxx没有响应”和无响应的用户界面。
每次都不会发生这种情况,并且只有在使用部署版本时才会发生。 (即使我们在开发机器上进行测试)。
当我输入此消息时,我们正在启动并退出已部署的版本 很多次,为了尝试和重现行为...有时它会连续发生10次,然后它会在接下来的20次工作正常。没有迹象表明可能导致它的原因。 (只是成功实现)
只是为了告诉你我的意思,这是一个截图:
[] [空]
双击ListBox中的第一项时发生这种情况:
LLCOverviewPage llcOverview = new LLCOverviewPage((Controller)this.lstControllers.SelectedItem);
this.NavigationService.Navigate(llcOverview);
应用程序永远保持这种状态,不会抛出任何异常。
LLCOverViewPage的构造函数如下所示:
public LLCOverviewPage(Controller CurrentController)
{
InitializeComponent();
this.currentController = CurrentController.ToLightLinkController();
this.updateControllerInfo();
}
updateControllerInfo()方法显示页面上的信息, 然后调用方法更多先前已加载的信息 从SQL Compact 3.5数据库:
private void updateControllerInfo()
{
//Update the UI with general properties
this.lblDeviceName.Content = this.currentController.ShortName;
this.lblEthernetAddress.Content = this.currentController.Eth0.EthernetAddress.ToString();
this.lblTcpPort.Content = this.currentController.Eth0.TcpPort.ToString();
this.lblActuatorThroughputMode.Content = (this.currentController.Dali.ActuatorThroughputMode ? "Enabled" : "Disabled");
this.lblNetmask.Content = (this.currentController.Eth0.Netmask != null ? this.currentController.Eth0.Netmask.ToString() : String.Empty);
this.lblDefaultGateway.Content = (this.currentController.Eth0.DefaultGateway != null ? this.currentController.Eth0.DefaultGateway.ToString() : String.Empty);
//Update the UI with the ballasts
this.updateBallastList();
}
private void updateBallastList()
{
this.lstBallasts.ItemsSource = null;
List<BallastListViewItem> listviewItems = new List<BallastListViewItem>();
foreach (DaliBallast ballast in this.currentController.Dali.Ballasts.OrderBy(b => b.ShortAddress))
{
listviewItems.Add(new BallastListViewItem(ballast,this.currentController.SerialNumber));
}
this.lstBallasts.ItemsSource = listviewItems;
}
就是这样。构建页面时没有其他任何事情发生。
没有例外,因为应用程序没有崩溃, 我几乎没有什么可以继续找到出错的地方。
SQL Compact数据库存储在users应用程序文件夹中, 所以部署的版本使用与普通版本相同的数据库, 没有区别。
因此,为了清楚起见,此问题仅在部署版本中发生! (在Windows XP和Windows Vista的不同计算机上测试过)
任何可能导致此类事件发生的想法, 或者我可能会尝试什么来追查这个问题?
更新
使用一些好的旧调试(将日志信息写入文件) 我能够成功地确定所有代码 该应用程序仅在此之后冻结。
因此,如果再看一下正在创建的页面的构造函数:
public LLCOverviewPage(Controller CurrentController)
{
InitializeComponent();
this.currentController = CurrentController.ToLightLinkController();
this.updateControllerInfo();
}
this.updateControllerInfo()之后是应用程序冻结的地方 时。这会超出我的代码吗?也许是一个WPF错误?
更新2 我检查了Windows中的Application EventLog,这就是它所说的:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="Application Hang" />
<EventID Qualifiers="0">1002</EventID>
<Level>2</Level>
<Task>101</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2008-11-04T15:55:55.000Z" />
<EventRecordID>1630</EventRecordID>
<Channel>Application</Channel>
<Computer>DEVTOP</Computer>
<Security />
</System>
<EventData>
<Data>LLCControl.exe</Data>
<Data>1.0.0.0</Data>
<Data>2f4</Data>
<Data>01c93e95c29f9da5</Data>
<Data>20</Data>
<Binary>55006E006B006E006F0077006E0000000000</Binary>
</EventData>
</Event>
二进制文本说:UNKOWN,我猜我完全没有......
更新3 如果我将列表框的事件处理程序代码更改为:
LLCOverviewPage llcOverview = new LLCOverviewPage((Controller)this.lstControllers.SelectedItem);
MessageBox.Show("Navigating Now");
this.NavigationService.Navigate(llcOverview)
它向我显示该应用程序仅在导航时冻结!
更新4 我将一些事件处理程序连接到NavigationService。处理程序只需在触发事件时写入日志。结果如下:
17:51:35导航 17:51:35导航 17:51:35 LoadCompleted
那为什么这会被遗忘?
答案 0 :(得分:3)
我已经能够将问题追溯到代码了 在数据绑定发生时调用,这可以保证在这里找到一个新问题:
SQL 2 LINQ query (called by databinding) completely freezing WPF application