2

Possible Duplicate:
No Main() in WPF?

This is the code for Main() in WPF programming.

[STAThread]
public static void Main()
{
  Window win = new Window();
  ....

  Application app = new Application();
  app.Run(win);
}

However, when I tried to use VS2010 to make WPF Application.

enter image description here

I can't find the Main(), but public MainWindow().

enter image description here

Why is the Main() function hidden? How can I get the Main() when I use VS2010 WPF project?

Community
  • 1
  • 1
prosseek
  • 182,215
  • 215
  • 566
  • 871

3 Answers3

4

It is in .\obj\BuildConfiguration\app.g.cs

You can easily navigate to it by opening app.xaml.cs and use the right combobox above the source code to select the (grayed = resides in another partial-class file) main method.

springy76
  • 3,706
  • 2
  • 24
  • 46
2

The entry point is in App.xaml.cs. In there you could also override the OnStartup and pass in the cmd line arguments, if thats what you were wanting to do.

As others have mentioned, the question here answers what you are after.

Community
  • 1
  • 1
VoodooChild
  • 9,776
  • 8
  • 66
  • 99
1

Main() is generated during compilation.Find it in App.g.cs in obj/{Debug,Release} folder

bilash.saha
  • 7,226
  • 2
  • 35
  • 40