前言:
爲了解決程序開啓自啓動問題
參考資料
Custom Entry Points in WPF on .NET Core 鏈接 https://blog.magnusmontin.net/2020/01/31/custom-entry-point-wpf-net-core/
Creating a custom Main method in a WPF application 鏈接 https://www.meziantou.net/creating-a-custom-main-method-in-a-wpf-application.htm
這兩資料只看其一,不能成功設置。
自定義啓動入口
在點擊項目文件,進入項目文件中添加如下圖:
如果不添加,可以在 ...\obj\Debug\net6.0-windows 目錄下找到 App.g.cs 文件,此文件中定義了 Main 入口。
所以必須添加 <ApplicationDefinition Remove="App.xaml" /> 項。
在項目根目錄下創建 “Program.CS”文件,再添加 Main函數,如下圖:
在Main方法中啓動程序。如果發現程序,突然報錯很多 藍色線、紅色線,重啓 vs 2022 ,就消失了,然後再重新編譯。
我的倉庫
我的代碼倉庫 https://github.com/qiqiqiyaya/WPF/tree/main/Lesson%2010%20Practice/Practice
如果對你有幫助,給顆小星星