Skip to content
forked from jbevain/cecil

fork of cecil to use disk instead of ram for embedded resources (see readme)

License

Notifications You must be signed in to change notification settings

sahlaysta/cecil

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cecil

Fork of the Cecil library: https://github.com/jbevain/cecil

When modifying an assembly, adding many embedded resources would use an equally large amount of RAM. This fork fixes that by using a temp file for the resource buffer, so disk is used instead of RAM

NOTE: This fork is not a fix for large embedded resource files, but rather many smaller embedded resource files. For the former purpose, the solution is to split it into multiple embedded resource files a reasonable size, say 16 mb per split

Usage

Beforehand, set the static property: Mono.Cecil.EmbeddedResource.EmbeddedResourceStream as shown in this usage example

using Mono.Cecil;
using System;
using System.IO;

namespace Program
{
    class Program
    {
        static void Main(string[] args)
        {
            //create and set temp file
            const string tempFilePath = @"C:\temp.tmp";
            var tempFile = new FileStream(
                tempFilePath,
                FileMode.Create,
                FileAccess.ReadWrite); //readwrite required
            Mono.Cecil.EmbeddedResource.EmbeddedResourceStream = tempFile;
            try
            {
                using (tempFile)
                using (var assembly = AssemblyDefinition.ReadAssembly(@"C:\assembly.exe"))
                {
                    //(do stuff)
                    
                    //write assembly
                    assembly.Write(@"C:\newassembly.exe");
                }
            }
            finally
            {
                Mono.Cecil.EmbeddedResource.EmbeddedResourceStream = null;
                File.Delete(tempFilePath);
            }
        }
    }
}

About

fork of cecil to use disk instead of ram for embedded resources (see readme)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%