SecurityException: ECall methods must be packaged into a system module
问题 I have a (C#) function similar to the following. private static bool SpecialCase = false; public void Foo() { if (SpecialCase) { InternalMethod(); return; } Console.WriteLine(); } [MethodImpl(MethodImplOptions.InternalCall)] private static extern void InternalMethod(); When I execute this with the .NET Framework 4 inside the debugger, the method successfully prints blank line to the console and returns. When I execute it outside the debugger, it throws an exception with the following message: