Mono.Cecil convert .exe to dll?

By : Peter
Source: Stackoverflow.com
Question!

Is there any way to use Mono.Cecil to convert a exe to a dll, (removing the icon and other unneeded data, removing EntryPoint)

    AssemblyDefinition sourceAssembly = AssemblyDefinition.ReadAssembly(file);
    sourceAssembly.EntryPoint = null;
    sourceAssembly.Write(outputFile);

does not seem to have any effect at all..

By : Peter


Answers
To convert a managed .exe to a .dll, you can use:

var file = "foo.exe";
var module = ModuleDefinition.ReadModule (file);
module.Kind = ModuleKind.Dll;
module.EntryPoint = null;
module.Write (Path.ChangeExtension (file, ".dll"));

One thing that isn't implemented yet as of Cecil 0.9.5, is that you can not remove the Win32 icon programmatically. This is bug #3.

Fun fact: some .dll of the .net framework do have an entry point.

By : Jb Evain


This video can help you solving your question :)
By: admin