Reputation: 21755
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.
We deploy the application over the internet using ClickOnce and most of the time this does not cause any problems.
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).
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:
[][null]
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.
The constructor for the LLCOverViewPage looks like this:
public LLCOverviewPage(Controller CurrentController)
{
InitializeComponent();
this.currentController = CurrentController.ToLightLinkController();
this.updateControllerInfo();
}
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.
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.
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?
UPDATE
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();
}
After the this.updateControllerInfo() is where the application freezes from time to time. Would this be something beyond my code? Perhaps a WPF bug?
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...
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!
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 Navigating 17:51:35 Navigated 17:51:35 LoadCompleted
So why is this going to oblivion?
Upvotes: 2
Views: 1519
Reputation: 21755
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 query (called by databinding) completely freezing WPF application
Upvotes: 3