It seems that this might be relevant to your case: How are DLLs loaded by the CLR?
So you could do:
using System;
using System.Reflection;
public class Utilities {
public static Object LoadCustomCls(string file) {
Assembly a = Assembly.LoadFrom(file) ;
return a.CreateInstance("namespace.someclass") ;
}
}
And calling LoadCustomCls(file).DoSomething()
might work.
Notice that there is a deeper question here. Are we talking about a security boundary or a code boundary? Why do you need to force this restriction?
Because I am not sure anything you would do , would be a security boundary, as long as you run in the same process. And about the general availability of the assembly, I don't understand why does it matter.
PS. noticed just now that you want python. I am sure it is possible to do the equivalent in python / to call this C# code directly (ie through the clr.AddReference ).