2

I just started learning Prism and trying to use it with MEF in a test WPF application.
Based on "WPF Hands-On Lab: Get Started with the Prism Library" example in the Prism4 documentation, in a test WPF project I renamed MainWindow class to Shell.
My Bootstrapper class has the following code (also based on the Lab example):

class Bootstrapper : MefBootstrapper
{
    protected override DependencyObject CreateShell()
    {
         return new Shell();
    }

    protected override void InitializeShell()
    {
        Application.Current.MainWindow = (Shell)this.Shell;
        Application.Current.MainWindow.Show();
    }
    ...

App.xaml.cs code:

public partial class App : Application
{
    protected override void OnStartup(StartupEventArgs e)
    {
        base.OnStartup(e);
        Bootstrapper bootstrapper = new Bootstrapper();
        bootstrapper.Run();
    }
}

When I try to run the app even without exporting any module in it, I get an error:
"Cannot locate resource 'mainwindow.xaml'."

What am I doing wrong?

rem
  • 16,745
  • 37
  • 112
  • 180
  • Thanks to @Shiraz Bhaiji I found out that my App.xaml still has the attribute `StartupUri="MainWindow.xaml"` It should be deleted. And this is pointed out in the above mentioned Prism4 documentation: "Open the App.xaml file and remove the attribute StartupUri. Because you are manually instantiating the shell window in your bootstrapper, this attribute is not required." I just missed this point. – rem Feb 14 '11 at 20:33

1 Answers1

1

When you renamed your class did mainwindow.xaml get renamed to shell.xaml?

But the code/config is still pointing to the original name.

Shiraz Bhaiji
  • 64,065
  • 34
  • 143
  • 252
  • 2
    Yes, my mainwindow.xaml get renamed to shell.xaml. And do you mean App.xaml string StartupUri="MainWindow.xaml"? Yes, after deleting it the error's gone. Thank you! +1 – rem Feb 14 '11 at 20:24
  • HAd the same issue, am presently setting up the PRISM WPF enterprise level app! going through all possible hurdles met by others! too bad, i couldnt mark ur comment as answer – ioWint Jul 14 '11 at 05:41