12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- 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("出现异常:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + VersionNumber + "\r\n类型:{0}\r\n消息:{1}", errorTypeName, errorMessage);
- string errorStr = 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 = errorStr + "\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();
- }
- }
- }
|