To load assemblies in the same AppDomain but not block files after loading, simply use the LoadFrom method as follows:
Assembly asm = Assembly.LoadFrom( "mydll.dll" );
that way you’ll end and the session will be available.
there will be a problem with the debugger, because the characters (* .pdb) will not be loaded, so there is no breakpoint and no debugging, in order to be able to debug you, you really need to load .pdb files into memory, for example using FileStream.
Edit:. How you can make it so that the characters are loaded and not blocked, you need to use the appropriate Assembly.Load overload, which receives two bytes [] for the assembly and another for the assembly's symbol file (.pdb file):
public static Assembly Load( byte[] rawAssembly, byte[] rawSymbolStore )
in fact, you must first load the bytes with the stream, and then call Assembly.Load and pass the byte []
EDIT 2:
here is a complete example of loading assemblies in your current domain, including a symbol file and no file locking.
this is a complete example found on the web, it reflects everything you need, including handling AppDomain.AssemblyResolve ...
public static void Main() { AppDomain currentDomain = AppDomain.CurrentDomain; currentDomain.AssemblyResolve += new ResolveEventHandler(MyResolver); } static void InstantiateMyType(AppDomain domain) { try {
source share