I have my own DLL which I secure with ConfuserEx. In the ConfuserEx I'm using the "rename" protection:
<protection id="rename">
<argument name="mode" value="unicode" />
<argument name="renEnum" value="true" />
</protection>
This of course secures the DLL from viewing the code, but my class (which I have secured as part of a DLL), uses:
MethodInfo mi = typeof(MyClass).GetMethod(nameof(MyStaticMethod), BindingFlags.Static | BindingFlags.NonPublic);
Here the problem starts, because even my own code cannot find and use my (protected by ConfuserEx) method. I use GetMethod to call: Delegate.CreateDelegate. What can I do to solve this problem?
I'm still not sure why you can't just create the delegate you need directly without reflection, but if you really need to get the
MethodInfo, try doing something like this:That is, use your own locally defined delegate that matches the other delegate definition, create an instance of it directly in your code and then extract the
MethodInfofrom that instance.This code will be using a method token to identify
DoStuffrather than its name so should survive obfuscation without issue.