1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace LYFZ.ComponentLibrary
- {
- public partial class frmExceptionError : Form
- {
- public frmExceptionError()
- {
- InitializeComponent();
- this.Shown += frmExceptionError_Shown;
-
- }
- string _VersionNumber = "";
- public string VersionNumber
- {
- get { return _VersionNumber; }
- set { _VersionNumber = value; }
- }
- public void SetErrorInfo()
- {
- int errCode = System.Runtime.InteropServices.Marshal.GetLastWin32Error();//获取错误码。
- string ErrorMessages = LYFZ.WinAPI.Win32.GetSysErrMsg(errCode);
- this.lbErrorMsg.Text = string.Format("程序在运行时发生错误,建议您关闭后重试,也可以把错误报告给开发工程师以便修复此问题!\r\n出现应用程序未处理的异常:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + VersionNumber + "\r\n异常类型:{0}\r\n异常消息:{1}", errorTypeName, errorMessage);
- this.txtErrorInfo.Text = this.lbErrorMsg.Text + "\r\nLastWin32Error代码 " + errCode.ToString() + ":"+errorMessage+"\r\n" + errorStackTrace;
- }
- void frmExceptionError_Shown(object sender, EventArgs e)
- {
- SetErrorInfo();
- }
- string errorTypeName = "";
- /// <summary>
- /// 异常类型
- /// </summary>
- public string ErrorTypeName
- {
- get { return errorTypeName; }
- set { errorTypeName = value; }
- }
- string errorMessage = "";
- /// <summary>
- /// 异常消息
- /// </summary>
- public string ErrorMessage
- {
- get { return errorMessage; }
- set { errorMessage = value; }
- }
- string errorStackTrace = "";
- /// <summary>
- /// 堆栈信息
- /// </summary>
- public string ErrorStackTrace
- {
- get { return errorStackTrace; }
- set { errorStackTrace = value; }
- }
- private void buttonClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- }
- }
|