C# 什么是内部异常堆栈跟踪的结尾---

C# 什么是内部异常堆栈跟踪的结尾---,c#,C#,为什么在加载程序集时显示: Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationExcept ion: The type initializer for 'T???????????????????' threw an exception.

为什么在加载程序集时显示:

Unhandled Exception: System.Reflection.TargetInvocationException: Exception has
been thrown by the target of an invocation. ---> System.TypeInitializationExcept
ion: The type initializer for 'T???????????????????' threw an exception. ---> Sy
stem.TypeInitializationException: The type initializer for 'System.Management.Ma
nagementPath' threw an exception. ---> System.OutOfMemoryException: Exception of
 type 'System.OutOfMemoryException' was thrown.
   at System.Threading.Thread.StartInternal(IPrincipal principal, StackCrawlMark
& stackMark)
   at System.Threading.Thread.Start(StackCrawlMark& stackMark)
   at System.Threading.Thread.Start()
   at System.Management.MTAHelper.InitWorkerThread()
   at System.Management.MTAHelper.CreateInMTA(Type type)
   at System.Management.ManagementPath.CreateWbemPath(String path)
   at System.Management.ManagementPath..cctor()
   --- End of inner exception stack trace ---
   at System.Management.ManagementScope._Clone(ManagementScope scope, Identifier
ChangedEventHandler handler)
   at System.Management.ManagementObjectSearcher..ctor(ManagementScope scope, Ob
jectQuery query, EnumerationOptions options)
   at System.Management.ManagementObjectSearcher..ctor(String queryString)
   at T???????????????????..cctor()
   --- End of inner exception stack trace ---
   at T???????????????????.get_Is64Bit()
   at ????????????????????.????????????????????()
   at ????????????????????.????????????????????()
   at ????????????????????.Main(String[] args)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments,
 Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Objec
t[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invoke
Attr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at skip.Program.RunInternal(Byte[] encode, String pass)
   at skip.Program.Main()
在我的示例中,首先删除我的pe格式的标题:

[DllImport("kernel32.dll")]
        private static extern IntPtr ZeroMemory(IntPtr addr, IntPtr size);

        [DllImport("kernel32.dll")]
        private static extern IntPtr VirtualProtect(IntPtr lpAddress, IntPtr dwSize, IntPtr flNewProtect, ref IntPtr lpflOldProtect);

        [DllImport("kernel32.dll")]
        public static extern IntPtr GetModuleHandle(string lpModuleName);

        public static void EraseHeader()
        {
            IntPtr address = GetModuleHandle(null);
            IntPtr dwOld = default(IntPtr);
            VirtualProtect(address, (IntPtr)4096, (IntPtr)0x40, ref dwOld);
            ZeroMemory(address, (IntPtr)4096);
        }


        static void Main(string[] args)
        {
            Console.WriteLine("");
            EraseHeader();
            while(true)
                Console.WriteLine("");
            //Console.ReadKey();
        }
然后我加载我的程序集:

Assembly exeAssembly = Assembly.Load(Buffer);
object[] parameters = new object[1]; 
exeAssembly.EntryPoint.Invoke(null, parameters);
在结果中,向我显示以前的错误:

--- End of inner exception stack trace ---
为了便于学习,我想了解为什么显示此错误。

void ZeroMemory(IntPtr addr,IntPtr size);bool VirtualProtect(IntPtr lpAddress,IntPtr dwSize,int flNewProtect,out int lpflOldProtect)
“内部异常堆栈结束跟踪”只是向您显示嵌套异常的结束位置-它以“-->”开头
VirtualProtect(地址,(IntPtr)4096,(int)MemoryProtectionConsts.READWRITE,out lpflOldProtect);零存储器(地址,(IntPtr)4096)=相同的错误