I am trying to change the MainWindow
location in a WPF application from the default startup URI: MainWindow.xaml to Views\MainWindow.xaml. where Views
is a folder created inside the project folder.
Uri: this.StartupUri = new System.Uri(@"Views\MainWindow.xaml", System.UriKind.Relative);
I changed the uri and then the application breaks with the following error:
An unhandled exception of type 'System.TypeInitializationException'occurred in PresentationFramework.dll
Additional information: The type initializer for 'System.Windows.Application' threw an exception.
I placed breakpoints and try-catch blocks in the Main method,the InitializeComponent method and the MainWindow constructor to no avail.It crashes and i can't catch the exception.
Main:
public static void Main() {
try
{
wpfTest.App app = new wpfTest.App();
app.InitializeComponent();
app.Run();
}catch(Exception ex)
{
Console.WriteLine(ex.InnerException.Message);
}
}
Does the startupUri have to be changed somewhere else too?It has only one reference :the one in the InitializeComponent method.