سؤال

شيء غريب يحدث في قانون بلدي حيث أنا باستخدام تتبع مكدس الذاكرة المؤقتة. انها تقريبا كما لو لم يتم تحميل معلومات التصحيح ... ولكن أنا على التوالي هذا على ملفات DEBUG build.The .PDB وديفينيتيلي في الدليل بن وحتى الآن. لقد ركض على محمل الجد من ideeas:

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"
    }
}
هل كانت مفيدة؟

المحلول

وقليلا أكثر غوغلينغ وجدت: حول <لأ href = "http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/00281bbe-f2ee-488b-8133-74b0095d0c20" يختلط = "noreferrer "> هذا المنصب

وتبين تتبع مكدس الذاكرة المؤقتة لديها منشئ خاص

public StackTrace(bool fNeedFileInfo) 

وإذا كنت بحاجة إلى تقديم المعلومات إلى أن بالسكان. أوتش

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top