Friday, February 19, 2010

Crashing WPF app with Regional settings

Recently a buddy from the Support team came over and complained that Quorum stopped working on his (Vista, .NET 3.5SP1) machine suddenly.  Funny part is that the app kept crashing at the point of displaying the WPF window (splash screen) and we all assumed (burned by the previous experience) that it's the graphics driver issue.

Updating the drivers did not solve the problem and we were back to the machine Event log, where we noticed the following entry (Event 1001, name CLR20r3):




The machine did not have VS installed so we tried hooking-up the command line debugger (MDbg.exe) from the .NET SDK and the following exception was thrown:

Cannot convert string in attribute 'EndPoint' to object of type 'System.Windows.Point'. Premature string termination encountered.  Error at object 'System.Windows.Media.LinearGradientBrush' in markup file '...;component/wpfwindow.xaml' Line 20 Position 34."

Puzzled. The same code worked as a breeze on another machine with the same hardware (at least the graphics subsystem) and we started comparing the settings, installed apps, updates, etc.  The part of the message saying "Premature string termination encountered" indicated that something is wrong with the way the XAML is parsed and probably the delimiter cases were wrong.  But the regional settings were set to US English and there was nothing unusual.  Trying to change the list separator made no difference.  Then, the guy remembered that he wanted to test certain functionality on his machine as reported by the customer, so he played with regional settings trying to reproduce the bug.  Result was devastating: not just that he almost got the machine cleaned and paved with the fresh Vista installation, but he was also not able to help the customer asking for a totally different thing.

Googling the problem revealed the following MS KB entry:

FIX: An exception in the XAML parser is thrown when you run a WPF application on a computer that has customized English (United States) regional settings

Obviously, resetting the settings (changing to 'UK English' and then back to 'US English') did solve the problem, and luckily, we did not yet have reports from customers about similar situations.  The link above states that the fix can be obtained if the "MS Customer Support Center is contacted".  I still wonder why the update has not been released as hot-fix download or maybe even part of the Windows Update??  It remains to test the same behavior on .NET 4 and see.

Thursday, December 10, 2009

Microsoft Momentum 2009

Last month there was an MS event going on in Cyprus, Momentum 2009.  Being different from previous events, this one seemed to me as the best until now.  If nothing else but because of the venue where the event took place.

Usual MS events in Cyprus are 'played' at the hotel conference rooms while this year's Momentum had a full-size Hall within the Cyprus State Fair exhibition area.  Professionalism was on their side this time.

From the side of the CDNUG, we kept the Developers track (there was IT track going on in parallel) together with Karl.

I talked about Windows API CodePack and all nice UI goodies in Windows7.

Artemis has more details about the event and his session here.

General Dev. track review can be found on the CDNUG website here.

Sunday, October 11, 2009

Desktop app and Paging the results list

Probably something you have been burned with in the past, while working with the potentially large sets of data, was the efficient display methods. Ever since I started playing with the WPF and the powerful binding it brings, I have faced poor performance when binding substantial result sets to a ListBox for example.

Then, the virtualization comes along: being able to allow platform to render just the required number of results that are visible at the specific point of time provides much better results. I must admit that it was a cumbersome process at first, but the results were impressive and that made me understand the virtualization sooner than expected.

Now, since the problem with the performance is solved, we are good to go! But not so soon. Lately, I've hit another wall: filling the source with the data usually is what takes time and while pushing the hard work to another thread may give some more responsive UI, I have been (once more) challenged to look for a solution. The problem this time was the relatively slow response from the server and the data arrival was delayed due to many factors (net congestion, busy server, bad scaling, etc) so for the larger result set it would have rather disappointing results.

It may sound like a myth, but everyday Joe really does have kind of fate in the desktop apps when it's about speed. Things open instantaneously, response is short and in an event when there is a 1 second delay - it does not look nice. Trying to explain that the 10-year old MS Access app was much simpler, not scalable and insecure - doesn't improve the situation. Speed and response still remains an issue.

While that same everyday Joe "expects" the desktop app to fly, he/she has a completely different opinion when using the web based apps. The delays are expected (there were delays from the start), poor response even improves lately mostly due to the higher bandwidth or some AJAX here and there, but in essence, there are no complaints and things magically *work*.

One interesting point that we have had discussed within the team was how to tackle our problem of the slow server response while maintaining the UI speed and responsiveness? So, we thought about doing exactly what the web apps do when there are large result sets: page it!

Now, this was a challenge in the WinForm apps and the already familiar DataGrids (which are de-facto standard for the business desktop apps from the "battleship gray" era) were never designed to do so. Users always expected to see "everything" in a single shot, being able to sort, group, filter and whatever-else with a single mouse click. Adding paging to any of the DataGrid variants (third-party mostly) simply does not seem natural.

In WPF it seems like a good opportunity to re-arrange the user's opinion. While using some new ways of presenting the data that is far, far better (and different) from the battleship-gray style, we have a unique opportunity to bring results paging into the desktop apps. And the end-users seem not to complain! For them, a WPF app seems like a completely new experience and they are "easier" to accept new stuff. That is, provided that it still allows them to do their job.

Thursday, April 2, 2009

CDNUG community event

After so long time I've finally attended the latest CDNUG event on last Tuesday. It was good to meet and talk with Artemis and Evangelos.

Artemis spoke about Entity Framework and we all participated in the numerous demos.

I liked the exercises with the LINQ capabilities in combination with the Entity Framework.

Saturday, March 14, 2009

XElement.Value and the new line hell

Ever since I tried XElement, it always made me anxious when I had to workout few lines with the good, old System.Xml.XmlNode. Thanks to LINQ, we got these nice X* family of classes that are so much more easier and helpful.

Recently, we've moved the parts of our cache initialization methods to use XDocument and XElement instead. Some of the cache type classes contain multi-line strings usually displayed in a WinForms TextBox. Accessing the content of an element is simple as using the Value property.

textBoxNotes.Text = MyNode.Element("notes").Value;

In fact, everything works as expected, except the multi-line text. Property Value getter trims off the "\r" character from the string (which is required for the TextBox to actually show the text in the new line) and the lines appeared glued to each other in a single line.

Haven't found anything on this issue yet. It seems annoying to use:

Element("foo").Value.Replace("\n", "\n\r");

Saturday, July 1, 2006

MVP award

Just got an email with the subject "[MVP] Congratulations! You have received the Microsoft MVP Award".

At first I thought it was a spam and almost lost it! But then I read it again...

I'm still very surprised with the announcement and excited as well. The competency I've got the MVP award for is: Visual Developer - Client Application Development. This must be due to the activity in the our User Group and the subjects I used to cover in previous speaking engagements (WindowsForms and WPF).

MVP program offers many nice opportunities of connecting with fellow MVPs in the area and around the world. As an addition to that, you get the unofficial stuff directly from the Microsoft product teams and the ways to express your opinion.

Award is valid for one year and renewable based on the contributions to the community. I actually feel encouraged to do even more, as long as the time will allow. The ideas already started popping-up...

Wednesday, June 7, 2006

SQL 2005 Developers Marathon


We had successful event yesterday in the Cyprus College campus (Nicosia) about MS SQL Server 2005 called SQL Marathon. Chad delivered few sessions that were about all new features of SQL Server 2005 and the audience was very satisfied with the content.

We are looking forward to organize some larger scale events in November, mostly related to WinFX, Vista and Office 12.