运行ClickOnce部署版本的WPF应用程序时的奇怪行为

问题描述 投票:2回答:1

我们有一个基于导航的WPF应用程序。它直接从Visual Studio运行时工作正常,或者即使我们将文件复制到另一个目录或另一台计算机并在那里运行它。

我们使用ClickOnce在互联网上部署应用程序,大多数情况下这不会导致任何问题。

然而,它时不时地完全冻结,你会得到经典的“应用程序xxxx没有响应”和无响应的UI。

这不会每次都发生,并且仅在使用部署版本时才会发生。 (即使我们在开发机器上测试它)。

当我输入此消息时,我们开始并多次退出已部署的版本以尝试重现行为...有时它会连续发生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的不同计算机上测试过)

任何想法可能会导致这样的事情发生,或者我可能会尝试什么来追查这个问题?

UPDATE

使用一些好的旧调试(将日志信息写入文件)我能够确定我的所有代码都成功执行,之后应用程序只会冻结。

因此,如果再看一下正在创建的页面的构造函数:

    public LLCOverviewPage(Controller CurrentController)
    {
        InitializeComponent();

        this.currentController = CurrentController.ToLightLinkController();
        this.updateControllerInfo();            
    }

在this.updateControllerInfo()之后,应用程序不时冻结。这会超出我的代码吗?也许WPF错误?

更新2我检查了Windows中的应用程序事件日志,这就是它所说的:

<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>

二进制文字说:未知,猜猜我完全被打了...

更新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

那为什么这会被遗忘呢?

c# wpf linq debugging clickonce
1个回答
3
投票

我已经能够将问题追溯到数据绑定发生时被调用的代码,这可以保证在这里找到一个新问题:

SQL 2 LINQ query (called by databinding) completely freezing WPF application

© www.soinside.com 2019 - 2024. All rights reserved.