SetOutputStream() public method

Direct PE File output to an existing stream, instead of creating a new file.
public SetOutputStream ( Stream output ) : void
output Stream The output stream
return void
Ejemplo n.º 1
0
 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);
       }
 }
Ejemplo n.º 2
0
        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;
        }