为WPF项目添加Program.cs

1、新增Program.cs文件;

==========================

using System;
using System.Windows;

namespace WpfApp2
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
WpfApp2.App app = new WpfApp2.App();
app.InitializeComponent();
MainWindow windows = new MainWindow();
app.MainWindow = windows;
app.Run();
}
}
}

==========================

2、设置启动对象为Program.cs

项目右键 -> 属性 -> 启动对象

原文地址:https://www.cnblogs.com/sagerking/p/14468746.html