![](/img/trans.png)
[英]How to show filename and line number in stacktrace in azure function
[英]StackTrace filename unknown
在我使用StackTrace的代碼中發生了一些奇怪的事情。 這幾乎就像沒有加載調試信息一樣......但是我在DEBUG構建中運行它。.pdb文件在bin目錄中是最新的並且是最新的。 我已經嚴重失去了思想:
public class TraceHelper
{
private static IDictionary<string,int> TraceDictionary = new Dictionary<string,int>();
public TraceHelper(int duration)
{
...
TraceDictionary[InternalGetCallingLocation()]+=duration;
...
}
public static string InternalGetCallingLocation ()
{
var trace = new System.Diagnostics.StackTrace();
var frames = trace.GetFrames();
var filename = frames[1].GetFileName(); //<<-- this always returns null
return frames[0].ToString(); //this returns:
// "InternalGetCallingLocation at offset 99 in file:line:column <filename unknown>:0:0"
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.