public void init(string assemblyName, string stubName) { this.assemblyName = assemblyName; if (stubName == null) { string libPath = Fan.Sys.Sys.m_homeDir + "/lib/tmp"; if (!Directory.Exists(libPath)) Directory.CreateDirectory(libPath); this.fileName = libPath + "/" + assemblyName + ".dll"; } else { this.fileName = stubName; this.stubFileName = stubName; } peFile = new PEFile(fileName, assemblyName); if (!debug && !cache) { // Normally we have to write the dll to disk in order to get // the .pdb file. But if we don't need that, we can just // generate the whole assembly in memory buf = new MemoryStream(4096); peFile.SetOutputStream(buf); } }
internal static System.Reflection.Assembly Load(PEFile assembly) { MemoryStream binaryStream = new MemoryStream(); assembly.SetOutputStream(binaryStream); assembly.MakeDebuggable(false, false); assembly.WritePEFile(false); byte[] assemblyBytes = binaryStream.ToArray(); System.Reflection.Assembly loadedAssembly = System.Reflection.Assembly.Load(assemblyBytes); loaded.Add(loadedAssembly); return loadedAssembly; }