ow
This commit is contained in:
1 parent
90bb20e75f
commit
bcf82d0f45
8 files changed
+342
-37
No files matched your search
@@ -19,6 +19,13 @@ namespace WinFormsApp3
|
||||
[STAThread] // ← 加上这个,99% 立刻解决你的错误
|
||||
static int Main(string[] args)
|
||||
{
|
||||
// 全局未处理异常兜底:写日志而不是直接闪退,放到最前面
|
||||
AppDomain.CurrentDomain.UnhandledException += (s, e) =>
|
||||
{
|
||||
try { File.WriteAllText("crash.log", $"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] {(e.IsTerminating ? "FATAL" : "NON-FATAL")}\n{e.ExceptionObject}"); }
|
||||
catch { }
|
||||
};
|
||||
|
||||
// 命令行下载:WinFormsApp3.exe --download <视频地址> [--out 保存路径] [--referer 页面地址]
|
||||
if (args.Length > 0 && string.Equals(args[0], "--download", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
@@ -27,10 +34,15 @@ namespace WinFormsApp3
|
||||
}
|
||||
|
||||
ApplicationConfiguration.Initialize();
|
||||
|
||||
// 这里不能提前 form.Show():那会让 Form.Load 在消息循环开始之前执行,
|
||||
// WebView2 在没有消息泵时初始化会报 RPC_E_CHANGED_MODE,交给 Run 自己显示窗体
|
||||
Application.Run(new Form1());
|
||||
try
|
||||
{
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
File.WriteAllText("crash.log", $"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] Application.Run\n{ex}");
|
||||
throw;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user