次の C# コードを検討してください。
class Program
{
static public void Print(string toPrint)
{
Console.WriteLine(toPrint);
}
static void Main(string[] args)
{
Type program = typeof(Program);
MethodInfo methodInfo = program.GetMethod("Print", BindingFlags.Static | BindingFlags.Public);
methodInfo.Invoke(null, new object[] { "a" });
}
}
Visual Studio 2008 または Visual Studio 2008 で実行し、"Print" メソッド内に配置したブレークポイントにヒットすると、コールスタック ウィンドウに次のように表示されます。
ConsoleApplication4.exe!ConsoleApplication4.Program.Print(string toPrint)
[管理された移行にネイティブ]
【マネージドからネイティブへの移行】
ConsoleApplication4.exe!ConsoleApplication4.Program.Main(文字列[]引数)
RuntimeMethodInfo.Invoke
コールスタックに表示されないのはなぜですか? 結局のところ、これは管理されたメソッドなので、期待どおりに表示されないのはなぜですか?
また、一般的に、ここでのルールは何ですか? コールスタックから欠落していると予想されるマネージ メソッドはどれですか?