1
Vote

temporary files not deleted (reason found)

description

The temporary files holding the compressed assemblies are not deleted, thus the machine is flooded over time.
 
In ExeCompressor.GenerateLoader() these files are opened dor read access and the stream is passed to ModuleBuilder.DefineManifestResource().

comments

unittester wrote May 10, 2012 at 2:48 PM

Unintentionally saved, this additional lines here:

After the last line within ExeCompressor.GenerateLoader(), i.e.
assemblyBuilder.Save(options.OutputFileName);
all these files must be closed.

Proposal:

var compressedAssemblyStreams = new List<FileStream>();
...
// add compressed assemblies as private resources (streams remain open)
foreach (var resource in resources)
{
var stream = File.OpenRead(temp[resource]);
compressedAssemblyStreams.Add(stream);
module.DefineManifestResource(resource, stream, ResourceAttributes.Private);
}
...
// close all compressed assembly streams
foreach (var stream in compressedAssemblyStreams)
{
stream.Dispose();
}

wrote Feb 14, 2013 at 1:35 AM