ildasm and dynamic exe files

Posted by TonyNeallon on Stack Overflow See other posts from Stack Overflow or by TonyNeallon
Published on 2010-04-06T14:13:59Z Indexed on 2010/04/08 21:13 UTC
Read the original article Hit count: 369

Hi There, I am trying to create an application can modify properties in IL to create a slightly different executable. E.g Client A runs app and a label on the WinForm label Reads "Client A:". Client B runs the app and Label Says "Client B". Easy I know using config files or resource files but thats not an option for this project. The Main program needs to be able to generate .exe file dynamically based on some form fields entered by user.

My solution was to create a standalone executable that contained all the elements which I needed to make dynamic. I then used ildasm to generate the IL and thought that I could use this IL and substitute tags for the elements i wanted to make dynamic. I could then replace those tags at runtime after user filled the form using regex etc. The problem is, the if i re save the IL file generated by ILDASM as an exe and try to run it. I just launches console and does nothing.

Am I going about this the wrong way? I didnt want to delve into Reflection as the dynamic .exe is a really simple one and I thought reverse engineering IL with ildasm would be the quickest way.

You thoughts and pointers are much appreciated. Tony

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET