I'm using this guide to create a scripting platform inside my program.
I'd like to sandbox what they are allowed to do and what not.
I have a few namespaces that I'd like to only allow the code from using it and pretty much disallow everything else.
The assembly compiled from the custom code at runtime is linked to the main program via code I found:
foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
{
try
{
string location = assembly.Location;
if (!String.IsNullOrEmpty(location))
{
parameters.ReferencedAssemblies.Add(location);
}
}
catch (NotSupportedException)
{
// this happens for dynamic assemblies, so just ignore it.
}
}
So that the mods (dynamically generated code at runtime) can communicate with the main program.
With my limited knowledge and research it seems like I need to create a custom AppDomain and use PermissionSet, but I'm not sure how I can achieve this.