SingingEels : Development Community & Resource

Login

Articles

  • ADO.NET (2)
  • ASP.NET (36)
  • LINQ (4)
  • Security (2)
  • Silverlight (3)
  • SQL (7)
  • Standards (5)
  • WCF (2)

Syndication

  • Articles RSS
  • Blogs RSS

Contribute

  • Our Authors List
  • Member Sign-Up
  • Suggestions Box
ASP.NET Hosting with MS SQL 2008 – Click Here!
Thursday, November 6, 2008 : 8:46 AM - (0 comments)

WPF Bug : "assembly used when compiling might be different"

Recently, we made the switch at my job to use WPF for our Windows apps (and even for new User Controls in existing apps). I'm absolutely loving WPF, and all of it's goodness. There have been a few learning curves, but all in all it's been worth it.

Yesterday, however, I found my first "stupid bug" in WPF. A "stupid bug" is a bug that doesn't even begin to make sense. I've already seen a bug that was simply the mistake of the developer at Microsoft who made the 'GroupBox' control. (Thanks "Dr. WPF" for figuring that one out and fixing it.)

But this bug is beyond me as to why it happens. I can't even begin to understand who to blame on the WPF team for this one :)

How to Recreate the Bug

To see this bug for yourself doesn't take much. I simply downloaded the WPFToolkit from CodePlex, and tried to use the DatePicker. After referencing the DLL, everything looks great in the designer (and in the XAML). But, if I run my app, I get this error:

Runtime error caused by using a WPF control from another DLL without specifying a name

What's the problem you might ask? Quite stupidly... you'll get this error if you don't have a "Name" property on your control.

That's it! From what I've seen, if you add a reference to an assembly that has WPF controls in it... you can use those controls, but if you don't give them a Name, then at runtime, you'll get an error.

Horribly stupid bug... but, it is a very simple fix (just add a name)!

Show Me The XAML!

Here's the XAML that will error at runtime:

<my:DatePicker />

Here's the XAML that will not error at runtime:

<my:DatePicker Name="blahblah" />

By the way, to add to the stupidity of this bug, you only have to name *one* of your DatePicker controls. So, if you have two on the same XAML page, you only have to name one of them and you won't get the error.

Developer / Architect / Author

Blog Archives

  • November 2008 - (1)
  • October 2008 - (2)
  • September 2008 - (2)
  • August 2008 - (3)
  • July 2008 - (1)
  • June 2008 - (3)
  • May 2008 - (2)
  • April 2008 - (2)
  • March 2008 - (4)
  • February 2008 - (2)
  • December 2007 - (2)
  • November 2007 - (1)
  • October 2007 - (4)
  • September 2007 - (9)
  • August 2007 - (7)

Related Ads

SingingEels.com as of Jan 05 2009 - 08:57:41 PM - (0.0937476)