Phil Whittaker
Phil Whittaker

Reputation: 434

Limiting AppDomain assemblies

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.

Upvotes: 3

Views: 94

Answers (1)

Guillaume86
Guillaume86

Reputation: 14384

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

Upvotes: 1

Related Questions