2009-10-30 15 views
22

मेरे कोड में कुछ अजीब हो रहा है जहां मैं एक स्टैकट्रेस का उपयोग कर रहा हूं। यह लगभग है जैसे डीबग जानकारी लोड नहीं की जा रही है ... लेकिन मैं इसे डेबग बिल्ड पर चला रहा हूं। .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" 
    } 
} 
+1

क्या आप पूरा पता दिखा सकते हैं? मदद करने के लिए और संदर्भ की आवश्यकता है। – Richard

उत्तर

44

एक थोड़ा और अधिक arround googling पाया this post

बाहर कर देता है StackTrace यदि आप फ़ाइल जानकारी की आवश्यकता से भरा जा करने के लिए एक विशेष निर्माता

public StackTrace(bool fNeedFileInfo) 

है। ओच

+12

क्या बिल्ली है, यह मूर्खतापूर्ण आईएमओ है। – kizzx2

+4

गलत! बेईमानी! बेईमानी! – FastAl

संबंधित मुद्दे