The Sanbox sample on this page:
http://www.csscript.net/Samples.html gives some warning when compiled for ,NET 4.0.
PolicyLevel.CreateAppDomainLevel and AppDomain.CurrentDomain.SetAppDomainPolicy are obsolete. This link
http://go.microsoft.com/fwlink/?LinkID=155570 tells a way to work around this by editing you App.config file to allow use of the obsolete methods. That works, but I feel it better to switch to doing Sandboxing the way .NET 4.0 thinks you should do it.
Starting from the code shown at the bottom of the sanfboxing in .NET 4.0 example I adding these lines to the start of the main method:
string assemblyName = CSScript.Compile("Danger.cs");
File.Copy(assemblyName, Path.GetFullPath("Danger.dll"), true);
then changing the final line of the main method to be:
newDomainInstance.ExecuteUntrustedCode("Danger", "ClassA", "SayHello", null)
trying to run it the first line of the ExecuteUntrustedCode method throws:
Could not load file or assembly 'Compiled' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.
And I'm not sure what to do from there. Can someone with more experience with .NET Assembly loading tell me whats going on here, and show me how I can load an assembly generated with CSScript into a sandboxed environment.
Thanks.