当前位置: 首页>>代码示例>>C#>>正文


C# StackFrame.SetFileName方法代码示例

本文整理汇总了C#中System.Diagnostics.StackFrame.SetFileName方法的典型用法代码示例。如果您正苦于以下问题:C# StackFrame.SetFileName方法的具体用法?C# StackFrame.SetFileName怎么用?C# StackFrame.SetFileName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Diagnostics.StackFrame的用法示例。


在下文中一共展示了StackFrame.SetFileName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CaptureStackTrace

    	// PRIVATE method to retrieve an object with stack trace information
    	// encoded.
    	//
    	// This version leaves out the first "iSkip" lines of the stacktrace.
    	private void CaptureStackTrace(int iSkip, bool fNeedFileInfo, Thread targetThread,
                                       Exception e)
    	{
    		m_iMethodsToSkip += iSkip;
    
    		StackFrameHelper StackF = new StackFrameHelper(fNeedFileInfo, targetThread);
    
    		GetStackFramesInternal (StackF, 0, e);
    
    		m_iNumOfFrames = StackF.GetNumberOfFrames();

            if (m_iNumOfFrames != 0)
            {
                frames = new StackFrame [m_iNumOfFrames];

                for (int i=0; i<m_iNumOfFrames; i++)
                {
                    bool fDummy1 = true;
                    bool fDummy2 = true;
                    StackFrame sfTemp = new StackFrame (fDummy1, fDummy2);

                    sfTemp.SetMethodBase (StackF.GetMethodBase(i));
                    sfTemp.SetOffset (StackF.GetOffset(i));
                    sfTemp.SetILOffset (StackF.GetILOffset(i));

                    if (fNeedFileInfo)
                    {
                        sfTemp.SetFileName (StackF.GetFilename (i));
                        sfTemp.SetLineNumber (StackF.GetLineNumber (i));
                        sfTemp.SetColumnNumber (StackF.GetColumnNumber (i));
                    } 

                    frames [i] = sfTemp;
                }

                // CalculateFramesToSkip skips all frames in the System.Diagnostics namespace,
                // but this is not desired if building a stack trace from an exception.
                if (e == null)
                    m_iMethodsToSkip += CalculateFramesToSkip (StackF, m_iNumOfFrames);

                m_iNumOfFrames -= m_iMethodsToSkip;
                if (m_iNumOfFrames < 0)
                    m_iNumOfFrames = 0;
            }

            // In case this is the same object being re-used, set frames to null
            else
                frames = null;
    	}
开发者ID:ArildF,项目名称:masters,代码行数:53,代码来源:stacktrace.cs

示例2: CaptureStackTrace

        // Retrieves an object with stack trace information encoded.
        // It leaves out the first "iSkip" lines of the stacktrace.
        //
        private void CaptureStackTrace(int iSkip, bool fNeedFileInfo, Thread targetThread, Exception e)
        {
            m_iMethodsToSkip += iSkip;

            using (StackFrameHelper StackF = new StackFrameHelper(targetThread))
            {
                StackF.InitializeSourceInfo(0, fNeedFileInfo, e);

                m_iNumOfFrames = StackF.GetNumberOfFrames();

                if (m_iMethodsToSkip > m_iNumOfFrames)
                    m_iMethodsToSkip = m_iNumOfFrames;

                if (m_iNumOfFrames != 0)
                {
                    frames = new StackFrame[m_iNumOfFrames];

                    for (int i = 0; i < m_iNumOfFrames; i++)
                    {
                        bool fDummy1 = true;
                        bool fDummy2 = true;
                        StackFrame sfTemp = new StackFrame(fDummy1, fDummy2);

                        sfTemp.SetMethodBase(StackF.GetMethodBase(i));
                        sfTemp.SetOffset(StackF.GetOffset(i));
                        sfTemp.SetILOffset(StackF.GetILOffset(i));

#if FEATURE_EXCEPTIONDISPATCHINFO
                    sfTemp.SetIsLastFrameFromForeignExceptionStackTrace(StackF.IsLastFrameFromForeignExceptionStackTrace(i));
#endif // FEATURE_EXCEPTIONDISPATCHINFO

                        if (fNeedFileInfo)
                        {
                            sfTemp.SetFileName(StackF.GetFilename(i));
                            sfTemp.SetLineNumber(StackF.GetLineNumber(i));
                            sfTemp.SetColumnNumber(StackF.GetColumnNumber(i));
                        }

                        frames[i] = sfTemp;
                    }

                    // CalculateFramesToSkip skips all frames in the System.Diagnostics namespace,
                    // but this is not desired if building a stack trace from an exception.
                    if (e == null)
                        m_iMethodsToSkip += CalculateFramesToSkip(StackF, m_iNumOfFrames);

                    m_iNumOfFrames -= m_iMethodsToSkip;
                    if (m_iNumOfFrames < 0)
                    {
                        m_iNumOfFrames = 0;
                    }
                }

                // In case this is the same object being re-used, set frames to null
                else
                    frames = null;
            }
        }
开发者ID:,项目名称:,代码行数:61,代码来源:

示例3: CaptureStackTrace

 private void CaptureStackTrace(int iSkip, bool fNeedFileInfo, Thread targetThread, Exception e)
 {
     this.m_iMethodsToSkip += iSkip;
     StackFrameHelper sfh = new StackFrameHelper(fNeedFileInfo, targetThread);
     GetStackFramesInternal(sfh, 0, e);
     this.m_iNumOfFrames = sfh.GetNumberOfFrames();
     if (this.m_iMethodsToSkip > this.m_iNumOfFrames)
     {
         this.m_iMethodsToSkip = this.m_iNumOfFrames;
     }
     if (this.m_iNumOfFrames != 0)
     {
         this.frames = new StackFrame[this.m_iNumOfFrames];
         for (int i = 0; i < this.m_iNumOfFrames; i++)
         {
             bool flag = true;
             bool flag2 = true;
             StackFrame frame = new StackFrame(flag, flag2);
             frame.SetMethodBase(sfh.GetMethodBase(i));
             frame.SetOffset(sfh.GetOffset(i));
             frame.SetILOffset(sfh.GetILOffset(i));
             if (fNeedFileInfo)
             {
                 frame.SetFileName(sfh.GetFilename(i));
                 frame.SetLineNumber(sfh.GetLineNumber(i));
                 frame.SetColumnNumber(sfh.GetColumnNumber(i));
             }
             this.frames[i] = frame;
         }
         if (e == null)
         {
             this.m_iMethodsToSkip += CalculateFramesToSkip(sfh, this.m_iNumOfFrames);
         }
         this.m_iNumOfFrames -= this.m_iMethodsToSkip;
         if (this.m_iNumOfFrames < 0)
         {
             this.m_iNumOfFrames = 0;
         }
     }
     else
     {
         this.frames = null;
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:44,代码来源:StackTrace.cs


注:本文中的System.Diagnostics.StackFrame.SetFileName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。