The Main() method is created automatically.
If you want to provide your own you have to (tested in VS2013, VS2017 and VS2019):
- Right-click App.xaml in the solution explorer, select Properties
- Change 'Build Action' to 'Page' (initial value is 'ApplicationDefinition')
Then just add a Main() method to App.xaml.cs. It could be like this:
[STAThread]
public static void Main()
{
var application = new App();
application.InitializeComponent();
application.Run();
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…