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.