How can I limit the reflection of certain assemblies?

In my .net application, I want to limit the reflection of certain assemblies. I want to say that I want my specific assembly to be reflected only by some predefined assemblies, not by anyone. How can i do this?

Edit:

This tool completely disables the dismantling and decompilation of the assembly. I want to allow some predefined assemblies to reflect this assembly, but limit it to others. I want something that needs to be declared a collection, for example. AssemblyOne gives AssemblyTwo permission that you can reflect me, so only AssemblyTwo should be able to reflect this with complete trust, no one else.

+3
source share
4 answers

The tool you are associated with basically compiles the entire application into native code. It doesn’t actually “close” the reflection or anything else, it just turns the application into something completely different, it is no longer bytecode, and not technically a .NET assembly.

Callers with full confidence can always use reflection on the .NET assembly and everything inside it. In addition to (a) obfuscation, which anyone with sufficient patience and determination can de-confuse, or (b) compilation into their own code, which will prevent any reflection (and many other useful functions), you cannot prevent this from happening, and you, of course , you can not limit it to specific assemblies.

ReflectionPermissionAttribute, , , ; , API- Reflection. .

? NSA, /, , . , Reflector / Reflection, API.

, , , , , , , .

+9

!: -)

, , . . , , , .

+4

, - . , , ? - , , - ?

, , - , , , , , - , , . , , , ( , POV), .

, - - , , (UX, , , ..). , , - "" , ( ). - , .

, "" , .

Again, you may have a good reason to block thoughts that I did not think about, but I rather doubt that it is worth the effort, and I would be inclined to believe that your energy would be better spent elsewhere ... as when creating this The code you want to block is even better.

+2
source

Source: https://habr.com/ru/post/1740496/


All Articles