Application has generated an exception that could not be handled.

jeall 2007-04-30 10:43:58
一个C#程序作的exe包。原来运行都没有问题,今天确报了以下错误:

Application has generated an exception that could not be handled.
Process id=0xa44(2628) , Thread id=0x560(1376)

Click OK to terminate the application.
Click CANCLE to debug the application.
...全文
485 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
marvelstack 2007-05-01
  • 打赏
  • 举报
回复
先实现全局的异常扑捉,在分析异常错误。
扑捉代码如下:

=====================================
使用全局事件扑捉
=====================================
using System;
using System.Windows.Forms;
//using Microsoft.Win32;

//注册全局的异常处理程序,扑获产生的异常。
namespace Zhengzuo.CSharpCode
{
static class Program
{

/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
if ( false == SingleInstance.HandleRunningInstance() )
{
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
//SystemEvents.SessionEnding += new SessionEndingEventHandler(SystemEvents_SessionEnding);

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FormMain());
}
}

//static void SystemEvents_SessionEnding(object sender, SessionEndingEventArgs e)
//{
// throw new Exception("The method or operation is not implemented.");
//}

static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{
throw new Exception("The method or operation is not implemented.");
}

static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
throw new Exception("The method or operation is not implemented.");
}
}
}
scow 2007-04-30
  • 打赏
  • 举报
回复
程序的问题,发生了未在代码中catch的异常,调试一下。

111,095

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧