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


C# StackFrame.GetILOffset方法代码示例

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


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

示例1: StackFrameInfo

            private StackFrameInfo(StackFrame frame)
            {
                SetStackMeta(frame);

                if (frame.GetILOffset() == -1)
                {
                    return;
                }

                string filename = null;
                try
                {
                    filename = frame.GetFileName();
                    if (filename != null)
                    {
                        LineNumber = frame.GetFileLineNumber();
                    }
                }
                catch (SecurityException)
                {

                }

                FileName = filename;
            }
开发者ID:thattolleyguy,项目名称:metrics-net,代码行数:25,代码来源:CLRProfiler.cs

示例2: ExceptionFrame

        /// <summary>
        /// Initializes a new instance of the <see cref="ExceptionFrame"/> class.
        /// </summary>
        /// <param name="frame">The <see cref="StackFrame"/>.</param>
        public ExceptionFrame(StackFrame frame)
        {
            if (frame == null)
                return;

            int lineNo = frame.GetFileLineNumber();

            if (lineNo == 0)
            {
                //The pdb files aren't currently available
                lineNo = frame.GetILOffset();
            }

            var method = frame.GetMethod();
            if (method != null)
            {
                Module = (method.DeclaringType != null) ? method.DeclaringType.FullName : null;
                Function = method.Name;
                Source = method.ToString();
            }
            else
            {
                // on some platforms (e.g. on mono), StackFrame.GetMethod() may return null
                // e.g. for this stack frame:
                //   at (wrapper dynamic-method) System.Object:lambda_method (System.Runtime.CompilerServices.Closure,object,object))

                Module = "(unknown)";
                Function = "(unknown)";
                Source = "(unknown)";
            }

            Filename = frame.GetFileName();
            LineNumber = lineNo;
            ColumnNumber = frame.GetFileColumnNumber();
        }
开发者ID:getsentry,项目名称:raven-csharp,代码行数:39,代码来源:ExceptionFrame.cs

示例3: StackFrameToString

 public static string StackFrameToString(StackFrame stackFrame)
 {
     StringBuilder sb = new StringBuilder();
     int intParam; MemberInfo mi = stackFrame.GetMethod();
     sb.Append("   ");
     sb.Append(mi.DeclaringType.Namespace);
     sb.Append(".");
     sb.Append(mi.DeclaringType.Name);
     sb.Append(".");
     sb.Append(mi.Name);
     // -- build method params           
     sb.Append("(");
     intParam = 0;
     foreach (ParameterInfo param in stackFrame.GetMethod().GetParameters())
     {
         intParam += 1;
         sb.Append(param.Name);
         sb.Append(" As ");
         sb.Append(param.ParameterType.Name);
     }
     sb.Append(")");
     sb.Append(Environment.NewLine);
     // -- if source code is available, append location info           
     sb.Append("       ");
     if (string.IsNullOrEmpty(stackFrame.GetFileName()))
     {
         sb.Append("(unknown file)");
         //-- native code offset is always available               
         sb.Append(": N ");
         sb.Append(string.Format("{0:#00000}", stackFrame.GetNativeOffset()));
     }
     else
     {
         sb.Append(Path.GetFileName(stackFrame.GetFileName()));
         sb.Append(": line ");
         sb.Append(string.Format("{0:#0000}", stackFrame.GetFileLineNumber()));
         sb.Append(", col ");
         sb.Append(string.Format("{0:#00}", stackFrame.GetFileColumnNumber()));
         if (stackFrame.GetILOffset() != StackFrame.OFFSET_UNKNOWN)
         {
             sb.Append(", IL ");
             sb.Append(string.Format("{0:#0000}", stackFrame.GetILOffset()));
         }
     }
     sb.Append(Environment.NewLine);
     return sb.ToString();
 }
开发者ID:Microshaoft,项目名称:Microshaoft.Common.Utilities.Net.4x,代码行数:47,代码来源:StackTraceHelper.cs

示例4: Default

		public void Default ()
		{
			StackFrame sf = new StackFrame ();
			Assert.AreEqual (0, sf.GetFileLineNumber (), "GetFileLineNumber");
			Assert.AreEqual (0, sf.GetFileColumnNumber (), "GetFileColumnNumber");
			Assert.IsTrue (sf.GetILOffset () >= 0, "GetILOffset");
			Assert.IsTrue (sf.GetNativeOffset () >= 0, "GetNativeOffset");
			Assert.AreEqual ("Default", sf.GetMethod ().Name, "GetMethod");
		}
开发者ID:dfr0,项目名称:moon,代码行数:9,代码来源:StackFrameTest.cs

示例5: FileName_LineNumber_ColumnNumber

		public void FileName_LineNumber_ColumnNumber ()
		{
			StackFrame sf = new StackFrame (String.Empty, Int32.MinValue, Int32.MaxValue);
			Assert.AreEqual (Int32.MinValue, sf.GetFileLineNumber (), "GetFileLineNumber");
			Assert.AreEqual (Int32.MaxValue, sf.GetFileColumnNumber (), "GetFileColumnNumber");
			Assert.IsTrue (sf.GetILOffset () >= 0, "GetILOffset");
			Assert.IsTrue (sf.GetNativeOffset () > 0, "GetNativeOffset");
			Assert.AreEqual ("FileName_LineNumber_ColumnNumber", sf.GetMethod ().Name, "GetMethod");
		}
开发者ID:dfr0,项目名称:moon,代码行数:9,代码来源:StackFrameTest.cs

示例6: FaultStackFrame

 /// <summary>
 /// Creates a new instance of the <see cref="WcfRawJson.ErrorHandling.FaultStackFrame"/> 
 /// class from an existing <see cref="System.Diagnostics.StackFrame"/>.
 /// </summary>
 /// <param name="frame">
 /// The <see cref="System.Diagnostics.StackFrame"/> object from which to derive this
 /// <see cref="WcfRawJson.ErrorHandling.StackFrame"/>
 /// </param>
 public FaultStackFrame(StackFrame frame)
 {
     this.FileColumnNumber = frame.GetFileColumnNumber();
     this.FileLineNumber = frame.GetFileLineNumber();
     this.FileName = frame.GetFileName();
     this.ILOffset = frame.GetILOffset();
     this.Method = frame.GetMethod().ToString();
     this.NativeOffset = frame.GetNativeOffset();
     this.Description = frame.ToString();
 }
开发者ID:ZaneKaminski,项目名称:wcf-raw-json,代码行数:18,代码来源:FaultStackFrame.cs

示例7: CallSite

        public CallSite(StackFrame frame)
        {
            Line = frame.GetFileLineNumber();
            File = frame.GetFileName();
            ILOffset = frame.GetILOffset();

            var method = frame.GetMethod();

            if (method != null)
                Method = new MethodInfo(method);
        }
开发者ID:niik,项目名称:RxSpy,代码行数:11,代码来源:CallSite.cs

示例8: Check

		// avoid replication of tests on all constructors (this is no 
		// problem because the stack is already set correctly). The 
		// goal is to call every property and methods to see if they
		// have any* security requirements (*except for LinkDemand and
		// InheritanceDemand).
		private void Check (StackFrame sf, bool checkFile)
		{
			int cn = sf.GetFileColumnNumber ();
			int ln = sf.GetFileLineNumber ();
			int il = sf.GetILOffset ();
			int no = sf.GetNativeOffset ();

			Assert.IsNotNull (sf.GetMethod (), "GetMethod");

			if (checkFile) {
				string fn = sf.GetFileName ();
			}
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:18,代码来源:StackFrameCas.cs

示例9: FormatLocation

        public static string FormatLocation(StackFrame frame)
        {
            StringBuilder location = new StringBuilder();

            location.Append(frame.GetMethod().DeclaringType.ToString());
            location.Append("=>");
            location.Append(frame.GetMethod().ToString());
            location.Append(" [");
            location.Append(frame.GetILOffset());
            location.Append(":");
            location.Append(frame.GetNativeOffset());
            location.Append("]");

            return location.ToString();
        }
开发者ID:autocar,项目名称:ircddotnet,代码行数:15,代码来源:Logger.cs

示例10: BuildExceptionFrame

        private static ExceptionFrame BuildExceptionFrame(StackFrame frame)
        {
            int lineNo = frame.GetFileLineNumber();

            if (lineNo == 0)
            {
                //The pdb files aren't currently available
                lineNo = frame.GetILOffset();
            }

            var method = frame.GetMethod();
            return new ExceptionFrame()
            {
                Filename = frame.GetFileName(),
                Module = (method.DeclaringType != null) ? method.DeclaringType.FullName : null,
                Function = method.Name,
                Source = method.ToString(),
                LineNumber = lineNo,
                ColumnNumber = frame.GetFileColumnNumber()
            };
        }
开发者ID:jalaziz,项目名称:raven-csharp,代码行数:21,代码来源:SentryStacktrace.cs

示例11: ExceptionFrame

        /// <summary>
        /// Initializes a new instance of the <see cref="ExceptionFrame"/> class.
        /// </summary>
        /// <param name="frame">The <see cref="StackFrame"/>.</param>
        public ExceptionFrame(StackFrame frame)
        {
            if (frame == null)
                return;

            int lineNo = frame.GetFileLineNumber();

            if (lineNo == 0)
            {
                //The pdb files aren't currently available
                lineNo = frame.GetILOffset();
            }

            var method = frame.GetMethod();
            Filename = frame.GetFileName();
            Module = (method.DeclaringType != null) ? method.DeclaringType.FullName : null;
            Function = method.Name;
            Source = method.ToString();
            LineNumber = lineNo;
            ColumnNumber = frame.GetFileColumnNumber();
        }
开发者ID:ehvattum,项目名称:raven-csharp,代码行数:25,代码来源:ExceptionFrame.cs

示例12: TraceLineForFrame

        private static AirbrakeTraceLine TraceLineForFrame(StackFrame frame)
        {
            var method = frame.GetMethod();

            var lineNumber = frame.GetFileLineNumber();
            if (lineNumber == 0)
                lineNumber = frame.GetILOffset();

            var fileName = frame.GetFileName();
            if (string.IsNullOrEmpty(fileName))
                fileName = method.ReflectedType != null ? method.ReflectedType.FullName : "(unknown)";

            return new AirbrakeTraceLine(fileName, lineNumber, method.Name);
        }
开发者ID:kayoom,项目名称:SharpBrake,代码行数:14,代码来源:ExceptionInformation.cs

示例13: TryGetStackFrameInfo

        private bool TryGetStackFrameInfo(StackFrame/*!*/ frame, out string/*!*/ methodName, out string/*!*/ fileName, out int line) {
            MethodBase method = frame.GetMethod();
            methodName = method.Name;

            fileName = (_hasFileAccessPermission) ? frame.GetFileName() : null;
            var sourceLine = line = frame.GetFileLineNumber();

            if (TryParseRubyMethodName(ref methodName, ref fileName, ref line)) {
                if (sourceLine == 0) {
                    RubyMethodDebugInfo debugInfo;
                    if (RubyMethodDebugInfo.TryGet(method, out debugInfo)) {
                        var ilOffset = frame.GetILOffset();
                        if (ilOffset >= 0) {
                            var mappedLine = debugInfo.Map(ilOffset);
                            if (mappedLine != 0) {
                                line = mappedLine;
                            }
                        }
                    }
                }

                return true;
            } else if (method.IsDefined(typeof(RubyStackTraceHiddenAttribute), false)) {
                return false;
            } else {
                object[] attrs = method.GetCustomAttributes(typeof(RubyMethodAttribute), false);
                if (attrs.Length > 0) {
                    // Ruby library method:
                    // TODO: aliases
                    methodName = ((RubyMethodAttribute)attrs[0]).Name;

                    if (!_exceptionDetail) {
                        fileName = null;
                        line = NextFrameLine;
                    }

                    return true;
                } else if (_exceptionDetail || IsVisibleClrFrame(method)) {
                    // Visible CLR method:
                    if (String.IsNullOrEmpty(fileName)) {
                        if (method.DeclaringType != null) {
                            fileName = (_hasFileAccessPermission) ? method.DeclaringType.Assembly.GetName().Name : null;
                            line = 0;
                        }
                    }
                    return true;
                } else {
                    // Invisible CLR method:
                    return false;
                }
            }
        }
开发者ID:yarrow2,项目名称:ironruby,代码行数:52,代码来源:RubyStackTraceBuilder.cs

示例14: StackFrameToString

        //--
        //-- turns a single stack frame object into an informative string
        //--
        private static string StackFrameToString(StackFrame sf)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            int intParam = 0;
            MemberInfo mi = sf.GetMethod();

            var _with1 = sb;
            //-- build method name
            _with1.Append("   ");
            _with1.Append(mi.DeclaringType.Namespace);
            _with1.Append(".");
            _with1.Append(mi.DeclaringType.Name);
            _with1.Append(".");
            _with1.Append(mi.Name);

            //-- build method params
            ParameterInfo[] objParameters = sf.GetMethod().GetParameters();
            ParameterInfo objParameter = null;
            _with1.Append("(");
            intParam = 0;
            foreach (ParameterInfo objParameter_loopVariable in objParameters)
            {
                objParameter = objParameter_loopVariable;
                intParam += 1;
                if (intParam > 1)
                    _with1.Append(", ");
                _with1.Append(objParameter.Name);
                _with1.Append(" As ");
                _with1.Append(objParameter.ParameterType.Name);
            }
            _with1.Append(")");
            _with1.Append(Environment.NewLine);

            //-- if source code is available, append location info
            _with1.Append("       ");
            if (sf.GetFileName() == null || sf.GetFileName().Length == 0)
            {
                _with1.Append(System.IO.Path.GetFileName(ParentAssembly().CodeBase));
                //-- native code offset is always available
                _with1.Append(": N ");
                _with1.Append(string.Format("{0:#00000}", sf.GetNativeOffset()));
            }
            else
            {
                _with1.Append(System.IO.Path.GetFileName(sf.GetFileName()));
                _with1.Append(": line ");
                _with1.Append(string.Format("{0:#0000}", sf.GetFileLineNumber()));
                _with1.Append(", col ");
                _with1.Append(string.Format("{0:#00}", sf.GetFileColumnNumber()));
                //-- if IL is available, append IL location info
                if (sf.GetILOffset() != StackFrame.OFFSET_UNKNOWN)
                {
                    _with1.Append(", IL ");
                    _with1.Append(string.Format("{0:#0000}", sf.GetILOffset()));
                }
            }
            _with1.Append(Environment.NewLine);
            return sb.ToString();
        }
开发者ID:maz0r,项目名称:jmmserver,代码行数:62,代码来源:UnhandledExceptionManager.cs

示例15: GetCurLine

		private static string GetCurLine(StackFrame sf)
		{
			if (sf.GetILOffset() != -1)
			{
				string s = null;
				try
				{
					s = sf.GetFileName();
				}
				catch (SecurityException)
				{
				}
				if (s != null)
				{
					return string.Format(" in {0}:line {1}", s, sf.GetFileLineNumber());
				}
			}
			return "";
		}
开发者ID:991899783,项目名称:DbEntry,代码行数:19,代码来源:SystemHelper.cs


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