运行ClickOnce部署的WPF应用程序版本时的奇怪行为 [英] Weird behaviour when running ClickOnce deployed version of WPF application

查看:53
本文介绍了运行ClickOnce部署的WPF应用程序版本时的奇怪行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

We have a Navigation Based WPF application. It works fine when running directly from Visual Studio, or even if we copy the files to another directory or another computer and run it there.

我们使用ClickOnce和大多数工具通过Internet部署该应用程序 不会造成任何问题.

We deploy the application over the internet using ClickOnce and most of the time this does not cause any problems.

但是有时它会完全冻结,您会得到 经典的应用程序xxxx没有响应"和无响应的UI.

Every now and then however, it just freezes completely and you get the classic "Application xxxx is not responding" and a non responsive UI.

这并非每次都发生,只有在使用已部署的版本时才会发生. (即使我们在开发机器上进行了测试).

This does not happen every time, and only when using the deployed version. (Even if we test this on the development machine).

当我键入此消息时,我们正在启动并退出已部署的版本 为了尝试重现该行为很多次...有时它将连续发生10次,然后在接下来的20次中可以正常工作.没有迹象表明可能是什么原因造成的. (设法做到了)

As I am typing this message, we are starting and quiting the deployed version many times in order to try and reproduce the behaviour... sometimes it will happen 10 times in a row, and then it'll work fine the next 20 times. With no indication as to what might be causing it. (Just managed to make it happen)

仅显示您的意思,以下是屏幕截图:

Just to show you what I mean, here's a screenshot:

[] [空]

双击列表框的第一项会发生这种情况:

This happened when double clicking the first item in the ListBox:

   LLCOverviewPage llcOverview = new LLCOverviewPage((Controller)this.lstControllers.SelectedItem);
   this.NavigationService.Navigate(llcOverview);

应用程序将永远保持这种状态,不会引发任何异常.

The application just remains in this state forever, no exception is thrown.

LLCOverViewPage的构造函数如下:

The constructor for the LLCOverViewPage looks like this:

public LLCOverviewPage(Controller CurrentController)
{
     InitializeComponent();

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

updateControllerInfo()方法在页面上显示信息, 然后调用一个方法更多先前已加载的信息 从SQL Compact 3.5数据库中获取:

The updateControllerInfo() method displays information on the page, and then calls a method more information that has been loaded previously from a SQL Compact 3.5 database:

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

就是这样.构建页面后,什么也没有发生.

That's about it. Nothing else happens when the page is constructed.

毫无例外,并且由于应用程序不会崩溃, 为了找出问题所在,我几乎没有其他事情要做.

With no exception and since the application does not crash, I have very little to go on in order to find what's going wrong.

SQL Compact数据库存储在用户应用程序文件夹中, 因此,部署的版本使用与普通版本相同的数据库, 没什么不同.

The SQL Compact database is stored in the users application folder, so the deployed version uses the same database as the normal version, no difference there.

因此,为了清楚起见,仅在部署版本中会出现此问题! (在装有Windows XP和Windows Vista的不同计算机上进行了测试)

So, just to be clear, this problem occurs ONLY in the deployed version! (Tested on different machines with both Windows XP and Windows Vista)

任何可能导致这种情况发生的想法, 或为了找到这个问题我可能会尝试些什么?

Any ideas as what might be causing something like this to happen, or what I might try in order to trace down this problem?

更新

使用一些不错的旧调试方法(将日志信息写入文件) 我能够确定我的所有代码成功执行,并且 该应用程序只会在此之后冻结.

Using some good old debugging (writing log information to a file) I was able to determine all of my code succesfully excecutes and the application only freezes after that.

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

So if you take another look at the constructor of the page being created:

    public LLCOverviewPage(Controller CurrentController)
    {
        InitializeComponent();

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

在this.updateControllerInfo()之后是应用程序冻结的位置 时.这会超出我的代码范围吗?也许是WPF错误?

After the this.updateControllerInfo() is where the application freezes from time to time. Would this be something beyond my code? Perhaps a WPF bug?

更新2 我在Windows中检查了Application EventLog,它是这样的:

Update 2 I checked the Application EventLog in Windows, this is what it says:

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

二进制文本说:未知,猜猜我完全受了...

The Binary text says: UNKOWN, guess I'm completely pooched...

更新3 如果我将列表框的事件处理程序代码更改为此:

UPDATE 3 If I change the event handler code for the listbox to this:

LLCOverviewPage llcOverview = new LLCOverviewPage((Controller)this.lstControllers.SelectedItem);
MessageBox.Show("Navigating Now");
this.NavigationService.Navigate(llcOverview)

它告诉我该应用程序仅在导航时冻结!

it shows me that the application only freezes when Navigating!

更新4 我将一些事件处理程序连接到NavigationService.当事件被触发时,处理程序只是简单地写入日志.结果看起来像这样:

UPDATE 4 I hooked up a few event handlers to the NavigationService. The handlers simply write to the Log when the events are triggered. The result looks like this:

17:51:35导航 17:51:35导航 17:51:35 LoadCompleted

17:51:35 Navigating 17:51:35 Navigated 17:51:35 LoadCompleted

那为什么要遗忘呢?

推荐答案

我已经能够将问题追溯到正在编写的代码中 发生数据绑定时调用,这值得在这里找到一个新问题:

I have been able to trace the problem down to the code being called when databinding occurs, which warrants a new question found here:

SQL 2 LINQ查询(由数据绑定)完全冻结WPF应用程序

这篇关于运行ClickOnce部署的WPF应用程序版本时的奇怪行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆