I want to create an application domain with default permissions and load assembly into the application domain with default privileges and execute the methods inside the assembly.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
You may take a look at the following article on MSDN. Or if you want to construct an instance of some type inside another AppDomain (assuming this type has a default constructor):
var domain = AppDomain.CreateDomain("NewAppDomain");
var path = @"C:workSomeAssembly.dll";
var t = typeof(SomeType);
var instance = (SomeType)domain.CreateInstanceFromAndUnwrap(path, t.FullName);
The instance variable returned with this method lives on your newly created application domain and you are ready to manipulate it.
Method 2
Perhaps this helps
Can I reload an assembly in Mono CSharpRepl?
var dom = AppDomain.CreateDomain("tmp");
dom.Load("System.Core");
AppDomain.Unload(dom);
See also
Using multiple versions of the same DLL
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0