WPF程序重写Main() 函数

VS 创建WPF程序时会自动创建对应的 App.xamlApp.xaml.cs 文件。其中 App.xaml 文件会在编译的时候自动生成对应的 App.g.cs ,该文件默认状态下已经包含 Main() 函数。如果需要自己重写Main函数,具体方式如下:

  1. 修改App.xaml文件的属性,从默认的ApplicationDefinitionPage ,此时编译将不会在App.g.cs 文件中产生Main函数
  2. 删除 App.xaml 文件中的 StartupUri="MainWindow.xaml"
  3. 在 App.xaml.cs 文件中的App 类下创建 Main函数
posted @ 2022-08-24 14:36  Jeffxue  阅读(119)  评论(0编辑  收藏  举报