tags:

views:

157

answers:

2

This error ocurr when I call System.Application.Run(); in a WPF application. There is no other call to method Run(). Someone did see this?

+2  A: 

Why would you need to call Run() manually? The framework does it for you if you have an Application derived object usually defined in a file called App.xaml.

If you go in your obj directory you'll find the auto generated file for the application object (file is called App.g.cs) and it has something similar to:

/// <summary>
/// App
/// </summary>
public partial class App : System.Windows.Application {

    /// <summary>
    /// InitializeComponent
    /// </summary>
    [System.Diagnostics.DebuggerNonUserCodeAttribute()]
    public void InitializeComponent() {

        #line 4 "..\..\App.xaml"
        this.StartupUri = new System.Uri("Window1.xaml", System.UriKind.Relative);

        #line default
        #line hidden
    }

    /// <summary>
    /// Application Entry Point.
    /// </summary>
    [System.STAThreadAttribute()]
    [System.Diagnostics.DebuggerNonUserCodeAttribute()]
    public static void Main() {
        gridsh.App app = new gridsh.App();
        app.InitializeComponent();
        app.Run();
    }
}

Notice it defines a static main which has the call to Run.

Aviad P.
Note that a way to be able to define your own `Main()` is to not define an App.xaml, and instead define `Main()` in App.cs, calling Application.Run() yourself.
Will Eddins
A: 

Hey,

No, if you didn't include another call to Run, maybe try deleting the file and recreating it...

Brian