Esempio n. 1
0
 internal void InitializeSourceInfo(int iSkip, bool fNeedFileInfo, Exception exception)
 {
     StackTrace.GetStackFramesInternal(this, iSkip, fNeedFileInfo, exception);
     if (!fNeedFileInfo)
     {
         return;
     }
     if (!RuntimeFeature.IsSupported("PortablePdb"))
     {
         return;
     }
     if (StackFrameHelper.t_reentrancy > 0)
     {
         return;
     }
     StackFrameHelper.t_reentrancy++;
     try
     {
         if (!CodeAccessSecurityEngine.QuickCheckForAllDemands())
         {
             new ReflectionPermission(ReflectionPermissionFlag.MemberAccess).Assert();
             new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Assert();
         }
         if (StackFrameHelper.s_getSourceLineInfo == null)
         {
             Type type = Type.GetType("System.Diagnostics.StackTraceSymbols, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", false);
             if (type == null)
             {
                 return;
             }
             MethodInfo method = type.GetMethod("GetSourceLineInfoWithoutCasAssert", new Type[]
             {
                 typeof(string),
                 typeof(IntPtr),
                 typeof(int),
                 typeof(IntPtr),
                 typeof(int),
                 typeof(int),
                 typeof(int),
                 typeof(string).MakeByRefType(),
                 typeof(int).MakeByRefType(),
                 typeof(int).MakeByRefType()
             });
             if (method == null)
             {
                 method = type.GetMethod("GetSourceLineInfo", new Type[]
                 {
                     typeof(string),
                     typeof(IntPtr),
                     typeof(int),
                     typeof(IntPtr),
                     typeof(int),
                     typeof(int),
                     typeof(int),
                     typeof(string).MakeByRefType(),
                     typeof(int).MakeByRefType(),
                     typeof(int).MakeByRefType()
                 });
             }
             if (method == null)
             {
                 return;
             }
             object target = Activator.CreateInstance(type);
             StackFrameHelper.GetSourceLineInfoDelegate value = (StackFrameHelper.GetSourceLineInfoDelegate)method.CreateDelegate(typeof(StackFrameHelper.GetSourceLineInfoDelegate), target);
             Interlocked.CompareExchange <StackFrameHelper.GetSourceLineInfoDelegate>(ref StackFrameHelper.s_getSourceLineInfo, value, null);
         }
         for (int i = 0; i < this.iFrameCount; i++)
         {
             if (this.rgiMethodToken[i] != 0)
             {
                 StackFrameHelper.s_getSourceLineInfo(this.rgAssemblyPath[i], this.rgLoadedPeAddress[i], this.rgiLoadedPeSize[i], this.rgInMemoryPdbAddress[i], this.rgiInMemoryPdbSize[i], this.rgiMethodToken[i], this.rgiILOffset[i], out this.rgFilename[i], out this.rgiLineNumber[i], out this.rgiColumnNumber[i]);
             }
         }
     }
     catch
     {
     }
     finally
     {
         StackFrameHelper.t_reentrancy--;
     }
 }