Question

The .NET Framework has great features to support compiling code at runtime and running it, to achieve some kinds of scripting functionalities. There are already some scripting engines available on CodeProject, and Microsoft has its own library as well.

I am working on a web automation software, I want to include the Microsoft scripting engine in the application.

The problem is the scripting engines allow Using all namespace, in the referenced assembly, and I want to restrict the usage to a selected few namespace.

using System; // allowed.
using System.Linq; // allowed.
using System.Reflection; // restrict.

How to restrict the use of namespaces, in the scripts.

Was it helpful?

Solution

Restricting namespaces by name doesn't accomplish much since the extension can just include a copy of the class you don't like in its own assembly, but just renamed.

It sounds like what you really want is a security boundary. Put the extension in an untrusted AppDomain.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top