Is it possible to limit or limit the amount of C # code that can be run from a DLL?

I am working on a project where I will allow users to write code that will be compiled, downloaded and launched, this code will allow users to control certain parts of the application. However, since this simply allows them to embed C # in a running application, there are certain limitations that I would like to have in place.

Is there a way you can run a piece of code, but allow any use of System.Threading or any System.IO ?

I know that through code and removing any links would be possible, but I'm sure there will be ways around this. Before writing this, I would at least want to check if there is a simpler and more efficient way.

I have googled, but either I'm looking in the wrong place, or I'm asking the wrong question. However, I know that you, people with stack overflows, are geniuses. Any ideas?

Thanks, and any answer would be greatly appreciated!

+4
source share
2 answers

Securing an access code may be what you are looking for.

+2
source

Instead of going through the code and deleting all the individual links, why not just limit the links to the project? In addition, you can use .NET permissions for the system using the .NET framework configuration snap-in to control access to GAC, domain applications, etc. Based on various parameters. (start> run> mscorcfg.msc to start it) I do not know that the new version 4.0 should replace this configuration utility. EDIT: To take this one step further, you can run, for example, the entered code with the user account of the service and restrict the access of this code through this utility.

0
source

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


All Articles