示例#1
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="x">Error exception.</param>
        /// <param name="stack">Current stack.</param>
        public wfrm_sys_Error(Exception x,System.Diagnostics.StackTrace stack)
        {
            InitUI();

            this.ClientSize = new Size(492,168);

            m_pMessage.Text = x.Message;
            string extenedMessage  = "Message: " + x.Message + "\r\n";
                   extenedMessage += "Method: " + stack.GetFrame(0).GetMethod().DeclaringType.FullName + "." + stack.GetFrame(0).GetMethod().Name + "()" + "\r\n\r\n";
                   extenedMessage += "Stack:\r\n" + x.StackTrace;
			m_pExtendedMessage.Text = extenedMessage;
        }
        /// <summary>
        /// Default constructor.
        /// </summary>
        public wfrm_Error(Exception x,System.Diagnostics.StackTrace stack)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //

            this.Height = 210;
            m_pImage.Image = imageList1.Images[0];

            m_pMessage.Text = x.Message;
            wEditBox1.Text = stack.GetFrame(0).GetMethod().DeclaringType.FullName + "." + stack.GetFrame(0).GetMethod().Name + "()";

            m_pErrorText.Text = x.StackTrace;
        }
示例#3
0
		/// <summary>
		/// 寫LOG相關函式
		/// </summary>
		/// <param name="xsLogMsg">Log的訊息</param>
		/// <param name="xiLogLevel">Log等級</param>
		/// <param name="xoSt">Log堆疊的呼叫</param>
		/// <returns>回傳寫LOG成功失敗訊息</returns>
        public bool write(string xsLogMsg, 
			              LogLevel xiLogLevel,
			              System.Diagnostics.StackTrace xoSt
			              )
        {
            if( xiLogLevel <= miLogLevel )
            {
                System.Diagnostics.StackFrame loSf = xoSt.GetFrame( 0 ) ;
                moWrite.WriteLine("{0} {1} {2} {3} {4} {5}" ,
                                  (int) xiLogLevel ,
                                  System.DateTime.Now.ToString( "yyyy-MM-dd HH:mm:ss.ffff" ) ,
                                  loSf.GetFileName(),
					              loSf.GetMethod().Name,
					              loSf.GetFileLineNumber() ,
                                  xsLogMsg
					              );
                moWrite.Flush() ;
                return true ;
            }
            else
            {
                return false ;
            }
        }
示例#4
0
 /// <summary>
 /// Populates TransactionSupportAttribute array within the last frame of given stacktrace instance.
 /// </summary>
 /// <param name="stack">Instance of current stack trace in the type of System.Diagnostics.StackTrace</param>
 /// <returns></returns>
 public static TransactionSupportAttribute[] GetCustomAttribute(System.Diagnostics.StackTrace stack)
 {
     if (null == stack) { return null; }
     return (TransactionSupportAttribute[])stack.GetFrame(1).GetMethod().GetCustomAttributes(typeof(TransactionSupportAttribute), true);
 }
		private void CollectStackTraceInfo (System.Diagnostics.StackTrace _stackTrace)
		{
			// Gathering information related to stackoverflow
			StringBuilder _desciptionBuilder	= new StringBuilder();
			int _totalFrames					= _stackTrace.FrameCount;
			int _totalFramesMinus1				= _totalFrames - 1;		

			// Append stacktrace info
			for (int _iter = 0; _iter < _totalFrames; _iter++)
			{
				StackFrame _stackFrame			= _stackTrace.GetFrame(_iter);

				// Method info
				MethodBase _method				= _stackFrame.GetMethod();
				string _methodName 				= _method.ToString();
				string _className 				= _method.DeclaringType.FullName;

				_desciptionBuilder.AppendFormat("{0}:{1}", _className, _methodName);

				// File info
				string _fileAbsolutePath		= _stackFrame.GetFileName();

				if (!string.IsNullOrEmpty(_fileAbsolutePath))
				{
					string _fileRelativePath		= GetRelativePath(_fileAbsolutePath);

					// Following unity standard stacktrace output "class-name:method-definition() (at relative-path:10)"
					_desciptionBuilder.AppendFormat("(at {0}:{1})", _fileRelativePath, _stackFrame.GetFileLineNumber());
				}

				if (_iter < _totalFramesMinus1)
					_desciptionBuilder.AppendLine();
			}

			// Set value
			StackTrace	= _desciptionBuilder.ToString();
		}