Royi Namir Royi Namir - 1 year ago 107
C# Question

How can I protect my private funcs against reflection executing?

After seeing this: Do access modifiers affect reflection also?

I tried using this, but it doesn't work:
enter image description here

How can I prevent reflection from executing my private methods?

Answer Source

If someone can currently use reflection on your private methods, then they already have enough access to sidestep anything else you place in their way. Running with less trust may be an option, but that is only to prevent things like plugins from having too much access - it won't stop a user with (say) admin access to the box, who can simply elevate the access.

If you don't want code running, don't put it in physical reach of the malicious user; keep it at a web-service or similar. Any code available to a user can be used directly, or indirectly by decompiling it (and deobfuscating it if needed). You can use some tricks to get in their way (checking the caller via the stacktrace etc), but that will not stop someone determined.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download