本文整理汇总了C#中System.Diagnostics.StackFrame.GetNativeOffset方法的典型用法代码示例。如果您正苦于以下问题:C# StackFrame.GetNativeOffset方法的具体用法?C# StackFrame.GetNativeOffset怎么用?C# StackFrame.GetNativeOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Diagnostics.StackFrame
的用法示例。
在下文中一共展示了StackFrame.GetNativeOffset方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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");
}
示例2: 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");
}
示例3: 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();
}
示例4: 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 ();
}
}
示例5: 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();
}
示例6: 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();
}
示例7: 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();
}
示例8: StackFrameToString
private static string StackFrameToString(StackFrame sf)
{
var sb = new StringBuilder();
MemberInfo mi = sf.GetMethod();
sb.Append(" ");
sb.Append(mi.DeclaringType.Namespace);
sb.Append(".");
sb.Append(mi.DeclaringType.Name);
sb.Append(".");
sb.Append(mi.Name);
var objParameters = sf.GetMethod().GetParameters();
sb.Append("(");
var intParam = 0;
foreach (var objParameter in objParameters)
{
intParam++;
if (intParam > 1)
{
sb.Append(", ");
}
sb.Append(objParameter.Name);
sb.Append(" As ");
sb.Append(objParameter.ParameterType.Name);
}
sb.Append(")");
sb.Append(Environment.NewLine);
sb.Append(" ");
if ((sf.GetFileName() == null) || (sf.GetFileName().Length == 0))
{
sb.Append(Path.GetFileName(ParentAssembly().CodeBase));
sb.Append(": N ");
sb.Append(string.Format("{0:#00000}", sf.GetNativeOffset()));
}
else
{
sb.Append(Path.GetFileName(sf.GetFileName()));
sb.Append(": line ");
sb.Append(string.Format("{0:#0000}", sf.GetFileLineNumber()));
sb.Append(", col ");
sb.Append(string.Format("{0:#00}", sf.GetFileColumnNumber()));
if (sf.GetILOffset() != -1)
{
sb.Append(", IL ");
sb.Append(string.Format("{0:#0000}", sf.GetILOffset()));
}
}
sb.Append(Environment.NewLine);
return sb.ToString();
}
示例9: StackFrameToString
private static string StackFrameToString(StackFrame sf)
{
var sb = new StringBuilder();
MemberInfo mi = sf.GetMethod();
sb.AppendFormat(" {0}.{1}.{2}",
mi.DeclaringType.Namespace,
mi.DeclaringType.Name,
mi.Name);
ParameterInfo[] parameters = sf.GetMethod().GetParameters();
sb.Append("(");
sb.Append(String.Join(", ", parameters.Select(p => String.Format("{0} {1}", p.ParameterType.Name, p.Name)).ToArray()));
sb.Append(")");
sb.AppendLine();
sb.Append(" ");
if (String.IsNullOrEmpty(sf.GetFileName()))
{
sb.Append(Path.GetFileName(ParentAssembly.CodeBase));
sb.Append(": N ");
sb.AppendFormat("{0:#00000}", sf.GetNativeOffset());
}
else
{
sb.Append(Path.GetFileName(sf.GetFileName()));
sb.AppendFormat(": line {0:#0000}, col {1:#00}", sf.GetFileLineNumber(), sf.GetFileColumnNumber());
if (sf.GetILOffset() != StackFrame.OFFSET_UNKNOWN)
{
sb.AppendFormat(", IL {0:#0000}", sf.GetILOffset());
}
}
sb.AppendLine();
return sb.ToString();
}
示例10: StackFrameToString
private static string StackFrameToString(StackFrame sf, ref string errorFrom)
{
StringBuilder sb = new StringBuilder();
int intParam;
MemberInfo mi = sf.GetMethod();
Type type = mi.DeclaringType;
string namspace = type.Namespace ?? string.Empty;
if (namspace.Equals("ExamineSystem.utility.eslog"))
{
return sb.ToString();
}
if (string.IsNullOrEmpty(errorFrom))
{
try
{
if (type.IsSubclassOf(typeof(System.Web.UI.Page)))
{
errorFrom = type.FullName;
}
else if (type.IsSubclassOf(typeof(System.Web.UI.Control)))
{
errorFrom = type.FullName;
}
else if (type.GetInterface("System.Web.IHttpHandler") != null)
{
errorFrom = type.FullName;
}
else if (type.GetInterface("System.Web.IHttpAsyncHandler") != null)
{
errorFrom = type.FullName;
}
else if (type.GetInterface("System.Web.IHttpModule") != null)
{
errorFrom = type.FullName;
}
else if (type.GetInterface("System.Web.IHttpHandlerFactory") != null)
{
errorFrom = type.FullName;
}
}
catch (Exception)
{
errorFrom = string.Empty;
}
}
sb.Append(" ");
sb.Append(namspace);
sb.Append(".");
sb.Append(type.Name);
sb.Append(".");
sb.Append(mi.Name);
// -- build method params
sb.Append("(");
intParam = 0;
foreach (ParameterInfo param in sf.GetMethod().GetParameters())
{
if (intParam > 0)
sb.Append(" , ");
sb.Append(param.Name);
sb.Append(" As ");
sb.Append(param.ParameterType.Name);
intParam += 1;
}
sb.Append(")");
sb.Append(Environment.NewLine);
// -- if source code is available, append location info
sb.Append(" ");
if (string.IsNullOrEmpty(sf.GetFileName()))
{
sb.Append("(unknown file)");
//-- native code offset is always available
sb.Append(": N ");
sb.Append(String.Format("{0:#00000}", sf.GetNativeOffset()));
}
else
{
sb.Append(System.IO.Path.GetFileName(sf.GetFileName()));
sb.Append(": line ");
sb.Append(String.Format("{0:#0000}", sf.GetFileLineNumber()));
sb.Append(", col ");
sb.Append(String.Format("{0:#00}", sf.GetFileColumnNumber()));
if (sf.GetILOffset() != StackFrame.OFFSET_UNKNOWN)
{
sb.Append(", IL ");
sb.Append(String.Format("{0:#0000}", sf.GetILOffset()));
}
}
sb.Append(Environment.NewLine);
return sb.ToString();
}
示例11: StackFrameToString
private static string StackFrameToString(StackFrame sf)
{
int intParam = 0;
var sb = new StringBuilder();
MemberInfo mi = sf.GetMethod();
{
//-- build method name
sb.Append(" ");
sb.Append(mi.DeclaringType.Namespace);
sb.Append(".");
sb.Append(mi.DeclaringType.Name);
sb.Append(".");
sb.Append(mi.Name);
//-- build method params
ParameterInfo[] objParameters = sf.GetMethod().GetParameters();
sb.Append("(");
intParam = 0;
foreach (var objParameter in objParameters)
{
intParam += 1;
if (intParam > 1) sb.Append(", ");
sb.Append(objParameter.Name);
sb.Append(" As ");
sb.Append(objParameter.ParameterType.Name);
}
sb.Append(")");
sb.Append(Environment.NewLine);
//-- if source code is available, append location info
sb.Append(" ");
if (string.IsNullOrEmpty(sf.GetFileName()))
{
sb.Append(Path.GetFileName(GetParentAssembly().CodeBase));
//-- native code offset is always available
sb.Append(": N ");
sb.Append(string.Format("{0:#00000}", sf.GetNativeOffset()));
}
else
{
sb.Append(Path.GetFileName(sf.GetFileName()));
sb.Append(": line ");
sb.Append(string.Format("{0:#0000}", sf.GetFileLineNumber()));
sb.Append(", col ");
sb.Append(string.Format("{0:#00}", sf.GetFileColumnNumber()));
//-- if IL is available, append IL location info
if (sf.GetILOffset() != StackFrame.OFFSET_UNKNOWN)
{
sb.Append(", IL ");
sb.Append(string.Format("{0:#0000}", sf.GetILOffset()));
}
}
sb.Append(Environment.NewLine);
}
return sb.ToString();
}
示例12: SourceCodeInformation
private string SourceCodeInformation(StackFrame frame)
{
if (String.IsNullOrEmpty(frame.GetFileName()))
return Path.GetFileName(_assemblyInfo.CodeBase) + ": N " + frame.GetNativeOffset();
return Path.GetFileName(frame.GetFileName()) + ": line " + frame.GetFileLineNumber()
+ ", col " + frame.GetFileColumnNumber() + ", IL " + frame.GetILOffset();
}