C#开发的程序,始终运行着,不知道什么原因关闭了,但进程还在,如何排除错误 RT谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 winform 在Program.cs 启动类里,加上异常抛出,弹出错误信息 /// <summary> /// 应用程序的主入口点。 /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); //處理UI執行緒異常 Application.ThreadException += Application_ThreadException; //處理非UI執行緒異常 AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Application.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture(ConfigurationManager.AppSettings.Get("ApplicationCulture")); Application.Run(new Login()); } #region 處理未捕獲異常的 static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) { Exception error = e.Exception as Exception; if (error != null) { string strMessage = String.Format("異常類型:{0}\n異常位置:{1}\n異常信息:{2}", error.GetType().Name, error.StackTrace, error.Message); } else { } } static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { Exception error = e.ExceptionObject as Exception; if (error != null) { string strMessage = String.Format("異常信息:{0}\n堆栈信息:{1}", error.Message, error.StackTrace); } else { } } #endregion 请LZ详细写说明 最好上图.. 你说的是不是开发的时候那个 xxx.vshost.exe进程文件啊.. 楼主可以进行如下的步骤处理:1.在您认为有错误的地方把log打出来进行分析;2.考虑到您重新启动应用程序后程序运行正常,建议使用windows 系统自带的性能分析工具进行内存分析,是不是调用了windows的API没有进行内存释放造成的 感觉还需要更多的信息才能分析。是winform还是windows service? 驻留了,进程,winword也经常这样 共通处理,封装异常类出LOG。 |WPFZYC| 在ASP.NET的页面代码中有OnError的方法来写出错处理,那我的一个类想实现这样的功能要怎么写 谢谢 c# 修改硬盘逻辑序列号有朋友会的吗? URL重写的问题 扑克牌的显示问题 Server.UrlEncode使用方法? C# asp.net页面问题!!!!请教.....困惑 关于自动登录上网的问题 求游戏开发高级技术人员 关键词:用户控件,设计时,运行时,环境变量,attribute [猫猫琪淑]dataGridView中新增行后保存报错,请高手进来指教!在线等... C#写界面 C++写算法 C#获取服务器上的IIS站点列表和各站点的详细信息
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
//處理UI執行緒異常
Application.ThreadException += Application_ThreadException;
//處理非UI執行緒異常
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Application.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture(ConfigurationManager.AppSettings.Get("ApplicationCulture"));
Application.Run(new Login());
} #region 處理未捕獲異常的
static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{
Exception error = e.Exception as Exception;
if (error != null)
{
string strMessage = String.Format("異常類型:{0}\n異常位置:{1}\n異常信息:{2}", error.GetType().Name, error.StackTrace, error.Message);
}
else
{
}
} static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
Exception error = e.ExceptionObject as Exception;
if (error != null)
{
string strMessage = String.Format("異常信息:{0}\n堆栈信息:{1}", error.Message, error.StackTrace);
}
else
{
}
} #endregion
1.在您认为有错误的地方把log打出来进行分析;
2.考虑到您重新启动应用程序后程序运行正常,建议使用windows 系统自带的性能分析工具进行内存分析,是不是调用了windows的API没有进行内存释放造成的