Alternative for reflection in ApplicationShellApplication.AfterShellCreated

Topics: Developer Forum
Jan 8, 2007 at 12:01 PM
The ApplicationShellApplication.AfterShellCreated method uses reflection to invoke the InitializeComponent method on the Application instance. This can be avoided by applying the following changes:

BankShell.App.cs:
- Add System.Windows.Markup.IComponentConnector as an inheritance (Contains InitializeMethod and Connect definitions).
- Add dummy Connect method:
void Connect(int connectionId, object target)
{
}

ApplicationShellApplication:
- Add IComponentConnector as constraint for TShell
- Change reflection code to:
(Shell as IComponentConnector).InitializeComponent();