Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Limiting AppDomain assemblies

Tags:

c#

.net

c#-4.0

When I first initialize an app domain it starts with 14 assemblies including mscor, System and others including System.Data

Is there a way for me to change define these starting assemblies?

Also in this new AppDomain I am compiling some code, the aim is to use this to limit the code that is compiled. If I add System.IO.File then it compiles fine, I want it to disallow this.

like image 439
Phil Whittaker Avatar asked Dec 03 '25 16:12

Phil Whittaker


1 Answers

For the second part of the question:

I don't think you can control compilation at that level.

You could use a c# parser to disallow some namespaces but I'm pretty sure somebody will find a way to get throuh that protection (with reflection, etc)

The safest way is IMHO to control the execution and not the compilation, you can control execution with sandboxing: http://msdn.microsoft.com/en-us/library/bb763046.aspx

like image 172
Guillaume86 Avatar answered Dec 06 '25 04:12

Guillaume86