如何防止私有方法被反射调用?

来源:互联网 发布:全自动风水罗盘软件 编辑:程序博客网 时间:2024/06/04 17:53

internal void Test()

{

if (new StackFrame(1).GetMethod().DeclaringType.AssemblyQualifiedName.Contains("mscorlib, "))

throw new Exception("Reflection is disabled!");

Console.WriteLine("Test!");

}