反射方法的.net模糊处理

反射方法的.net模糊处理,.net,reflection,obfuscation,.net,Reflection,Obfuscation,我想混淆我的申请。但是,我在其中使用了很多反射,特别是Type.GetMethod,以便创建具有动态类型的泛型方法 例: private void按钮1\u单击(对象发送者,事件参数e) { MethodInfo=this.GetType().GetMethod(“ShowInMessageBox”,System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic); MethodInfo gen

我想混淆我的申请。但是,我在其中使用了很多反射,特别是
Type.GetMethod
,以便创建具有动态类型的泛型方法

例:

private void按钮1\u单击(对象发送者,事件参数e)
{
MethodInfo=this.GetType().GetMethod(“ShowInMessageBox”,System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
MethodInfo generic=info.MakeGenericMethod(typeof(int));
String result=(String)generic.Invoke(这是一个新对象[]{1234});
MessageBox.Show(结果);
}
[混淆(排除=真)]
私有字符串ShowInMessageBox(T项)
{
return item.ToString();
}
但是,ConfuserExDotfuscator都不会更改
GetMethod(“ShowInMessageBox”)
中的字符串,因此一旦混淆,我的应用程序就无法工作


除了使用
[Obfuscation(Exclude=true)]
之外,还有其他方法可以成功地对反射的方法进行模糊处理吗?

在代码中给它们模糊的名称?您可以切换字符串以使用的
名称吗(
operator?nameof是个好主意,我同意。但是,它既不像ConfuserEx也不像Dotfuscator那样正确处理它们。
nameof
在编译时解析,结果与写入方法名称相同。根据实际使用情况,您可以使用cus实现方法/类型的解析tom使用属性而不是字符串。
        private void button1_Click(object sender, EventArgs e)
    {
        MethodInfo info = this.GetType().GetMethod("ShowInMessageBox", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
        MethodInfo generic = info.MakeGenericMethod(typeof(int));

        String result = (String)generic.Invoke(this, new Object[] { 1234 });

        MessageBox.Show(result);
    }

    [Obfuscation(Exclude =true)]
    private String ShowInMessageBox<T>(T item)
    {
        return item.ToString();
    }