Files
kami_itunes_june/AppleBatch_June/Program.cs
danial 06b0fcce08 chore(build): 更新项目配置和依赖以支持.NET 8
- 在.settings.local.json中添加dotnet clean命令权限
- 更新项目文件以启用不安全的二进制序列化和禁用平台兼容性警告
- 配置调试和发布模式的编译常量及优化选项
- 在解决方案文件中升级Visual Studio版本并添加多平台配置
- 移除FormLogin构造函数中的MessageBox调试代码
- 为过时的WebRequest、WebClient和ServicePointManager API添加编译警告抑制
- 简化异常处理逻辑并在Program.cs中改进启动流程
- 移除多个未使用的局部变量声明
- 添加launchSettings.json以支持开发环境配置
- 在表单构造函数中初始化components容器
- 优化网络请求超时设置并改善错误处理机制
2025-11-10 19:34:27 +08:00

64 lines
2.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AppleBatch_June
{
internal static class Program
{
[STAThread]
private static void Main()
{
// 调试断点测试 - 在此处设置断点
Console.WriteLine("程序开始启动 - Debug Breakpoint Test");
try
{
// 最小化启动过程避免CoreCLR初始化问题
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Console.WriteLine("Windows Forms 样式已启用");
// 设置全局异常处理
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.Automatic);
Application.ThreadException += (sender, e) => {
MessageBox.Show($"UI错误: {e.Exception.Message}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
};
AppDomain.CurrentDomain.UnhandledException += (sender, e) => {
MessageBox.Show($"未处理异常: {(e.ExceptionObject as Exception)?.Message}", "严重错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
};
Console.WriteLine("异常处理已设置");
// 尝试启动主窗体
try
{
Console.WriteLine("正在创建主窗体...");
Application.Run(new FormLogin());
}
catch (Exception ex)
{
Console.WriteLine($"窗体启动异常: {ex.Message}");
MessageBox.Show($"程序启动失败: {ex.Message}\n\n堆栈跟踪:\n{ex.StackTrace}", "启动错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
catch (Exception ex)
{
Console.WriteLine($"系统初始化异常: {ex.Message}");
MessageBox.Show($"系统初始化失败: {ex.Message}\n\n这是一个CoreCLR运行时错误可能的原因:\n" +
"1. .NET 8.0 运行时未正确安装\n" +
"2. 程序依赖项缺失\n" +
"3. 系统兼容性问题\n\n" +
"请确保已安装 .NET 8.0 Desktop Runtime。\n\n" +
"详细信息: {ex.StackTrace}", "CoreCLR 错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
Console.WriteLine("程序执行完成");
}
}
}
}