Avalon tip of the day
When an Avalon app starts up, it parses the XAML file, and as it parses the file, it creates the object tree.
Creating the object tree requires that the constructors for the objects be called. And if one of those constructors were to fail, you get a XamlParseException. Something like:
Cannot create instance of 'Window1' defined in assembly 'WindowsApplication4, Version=1.0.2480.23268, Culture=neutral, PublicKeyToken=null'. Exception has been thrown by the target of an invocation. Error in markup file 'Window1.xaml' Line 1 Position 9.
And then you spend a few minutes trying to figure out what is wrong with your XAML file that's making the parse fail. What's wrong with Line 1 Position 9...
If you see a XAML parse error, you might want to check that out. Or you could do things the right way and hook up to the Initialized or Loaded events instead of putting your code in the constructor.
Comments
Anonymous
October 16, 2006
I thought. Yea. D'uh. So what? But then I realized that having done tons of ASP.Net, it's just natural not to use the constructor and instead define a void Page_Load() {} to do control initialization tasks.Anonymous
October 17, 2006
Hey Eric, This is not regarding this post but rather about DVD Maker. In your FAQ, you had mentioned that an XML file can be passed to DVD Maker and then it'll finish off....what I want to know is the XML file will be only for the burning part or the encoding of MPEG-2 (+Dolby) content too...meaning can we pass an XML file to DVD Maker so that it'll encode the content in MPEG-2 (Dolby audio) and then burn it or that file is only for MPEG-2 complaint content only passed to DVD Maker for burning?Anonymous
October 17, 2006
The comment has been removedAnonymous
October 17, 2006
Makes sense, however; it does seem a little counter intuitive to how most people grok initialization and exception messages.Anonymous
October 27, 2006
The comment has been removedAnonymous
October 27, 2006
Tyler, My advice is to go and write some avalon code and do as much as possible through code rather than through XAML. I found it made a lot more sense to me to approach things that way initially, and convert to the XAML-based approach when I wanted to.