Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>to load the assemblies in the same AppDomain but not lock the files after load just use the <strong>LoadFrom</strong> method in this way:</p> <pre><code>Assembly asm = Assembly.LoadFrom( “mydll.dll” ); </code></pre> <p>in this way you are done and Session will be available.</p> <p>there will be an issue with the debugger because symbols (*.pdb) will not get loaded so no breakpoint and no debugging available, to be able to debug you should really load the .pdb files in memory as well, for example using FileStream.</p> <p><strong>Edit:</strong> The way you can do to also load symbols and not lock the files is to use proper overload of Assembly.Load, the one that gets two byte[] one for the assembly and the other for the assembly' symbols file (.pdb file):</p> <pre><code>public static Assembly Load( byte[] rawAssembly, byte[] rawSymbolStore ) </code></pre> <p>in fact you should first load the bytes with a stream then call Assembly.Load and pass the byte[]</p> <p><strong>EDIT 2:</strong></p> <p>here a full example to load the assemblies in your current domain, including the symbol file and not having the files locks.</p> <p>it's a full example found online, it reflect everything you need including the handling of AppDomain.AssemblyResolve...</p> <pre><code>public static void Main() { AppDomain currentDomain = AppDomain.CurrentDomain; currentDomain.AssemblyResolve += new ResolveEventHandler(MyResolver); } static void InstantiateMyType(AppDomain domain) { try { // You must supply a valid fully qualified assembly name here. domain.CreateInstance("Assembly text name, Version, Culture, PublicKeyToken", "MyType"); } catch (Exception e) { Console.WriteLine(e.Message); } } // Loads the content of a file to a byte array. static byte[] loadFile(string filename) { FileStream fs = new FileStream(filename, FileMode.Open); byte[] buffer = new byte[(int) fs.Length]; fs.Read(buffer, 0, buffer.Length); fs.Close(); return buffer; } static Assembly MyResolver(object sender, ResolveEventArgs args) { AppDomain domain = (AppDomain) sender; // Once the files are generated, this call is // actually no longer necessary. EmitAssembly(domain); byte[] rawAssembly = loadFile("temp.dll"); byte[] rawSymbolStore = loadFile("temp.pdb"); Assembly assembly = domain.Load(rawAssembly, rawSymbolStore); return assembly; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload