Create a .NET program that produces custom EXE's


I want to create a program that produces an executable slideshow.

So I need it to output an EXE with some required code and certain embedded resources (pictures) in it.

Does .NET provide such capability?


You can use CSharpCodeProvider class to compile code at runtime and add embedded resources. Have a look at this article where I explain how to do it: <a href="http://www.codeproject.com/Articles/19288/SlideShowBuilder" rel="nofollow">SlideShow Builder</a>


This is easy to accomplish.

You can add pictures as embedded resources and then use the technique of Reflection to discover and retrieve the embedded pictures.

So the program you write is independent of the list of pictures, which are just embedded resources. You can embed pictures as resources using Visual Studio, or create a custom program to do it.

You can find some examples at <a href="http://msdn.microsoft.com/en-us/library/aa287676(v=VS.71).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/aa287676(v=VS.71).aspx</a> and <a href="http://www.java2s.com/Code/CSharp/Development-Class/Saveandloadimagefromresourcefile.htm" rel="nofollow">http://www.java2s.com/Code/CSharp/Development-Class/Saveandloadimagefromresourcefile.htm</a>.

Good luck!


Like what SK-Logic said there is

<a href="http://msdn.microsoft.com/en-us/library/system.reflection.emit.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.reflection.emit.aspx</a>

here is example of that

<a href="http://olondono.blogspot.com/2008/02/creating-code-at-runtime.html" rel="nofollow">http://olondono.blogspot.com/2008/02/creating-code-at-runtime.html</a>

You could also create a the project file and create the code files and use the Process class to call the compiler if you want help doing this I can give an example


this will generate a process for you with the specified name (you'll still need to add code for the pictures):

public static Process GenerateRuntimeProcess(string processName, int aliveDuration, bool throwOnException = true) { Process result = null; try { AssemblyBuilder assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName() { Name = processName }, AssemblyBuilderAccess.Save); ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule(processName, processName + ".EXE"); TypeBuilder typeBuilder = moduleBuilder.DefineType("Program", TypeAttributes.Public); MethodBuilder methodBuilder = typeBuilder.DefineMethod("Main", MethodAttributes.Public | MethodAttributes.Static, null, null); ILGenerator il = methodBuilder.GetILGenerator(); il.UsingNamespace("System.Threading"); il.EmitWriteLine("Hello World"); il.Emit(OpCodes.Ldc_I4, aliveDuration); il.Emit(OpCodes.Call, typeof(Thread).GetMethod("Sleep", new Type[] { typeof(int) })); il.Emit(OpCodes.Ret); typeBuilder.CreateType(); assemblyBuilder.SetEntryPoint(methodBuilder.GetBaseDefinition(), PEFileKinds.ConsoleApplication); assemblyBuilder.Save(processName + ".EXE", PortableExecutableKinds.Required32Bit, ImageFileMachine.I386); result = Process.Start(new ProcessStartInfo(processName + ".EXE") { WindowStyle = ProcessWindowStyle.Hidden }); } catch { if (throwOnException) { throw; } result = null; } return result; }

you can findmore info on System.Reflection.Emit on MSDN <a href="http://msdn.microsoft.com/en-us/library/3y322t50.aspx" rel="nofollow">here</a> or a tutorial <a href="http://drdobbs.com/184416570" rel="nofollow">here</a> or <a href="http://blog.alxandr.me/2010/10/16/an-introduction-to-system-reflection-emit-and-opcodes/" rel="nofollow">here</a>.

if I were you I'd also look into just using powerpoint and/or the viewer app and some command line options as detailed <a href="http://office.microsoft.com/en-us/powerpoint-help/command-line-switches-for-powerpoint-2007-and-the-powerpoint-viewer-2007-HA010153889.aspx" rel="nofollow">here</a>. maybe you don't need to "make an app that makes another app that is a slideshow" at all..


  • Receiving a broadcast message in C# [duplicate]
  • C#: Find out result type of arithmetic operations in code (e.g. int + double = double)
  • Conflicting CLASS files
  • PHP OOP :: passing session key between classes
  • Generate setup.exe for ClickOnce deployment from command line using MSBuild
  • Pyrocms Contact form in facebook tabs - displaying errors on page load
  • Embed Barcode in C# PDF Library
  • Why can't I use constants in [SuppressMessage(…)] together with StyleCop?
  • How to escape “?” using regex in .htaccess for mod_rewrite
  • How to get current directory name in macros programming?
  • Invoking a Javascript from Lotus Notes on click of a button
  • jQuery - events won't fire for dynamically created tab elements
  • Can I have more than 32 netlink sockets in kernelspace?
  • app_Offline.htm doesn't work for subfolders of my application in IIS
  • how to get the drawing graphic on picture box in c#
  • How to read data from a text file if the file location is not known in c#?
  • View/Download Pdf Files in React - Router 4
  • Why does Sencha 2 only work in Webkit browsers?
  • How does the HEXTORAW() function work? What is the algorithm?
  • Are there any side effects from calling SQLAlchemy flush() within code?
  • Can I programmatically choose the Android layout folder?
  • Graphics.CopyFromScreen [Web application] + The handle is invalid
  • RxJava debounce by arbitrary value
  • Does Mobilefirst provide a provision to access web services directly?
  • ADO and msqli connections very slow
  • onBackPressed() not being executed
  • Display images in Django
  • print() is showing quotation marks in results
  • Word Open XML Mail Merge
  • Different response to non-authenticated users and AJAX calls
  • C# - Serializing and deserializing static member
  • Incrementing object id automatically JS constructor (static method and variable)
  • ActionScript 2 vs ActionScript 3 performance
  • Do create extension work in single-user mode in postgres?
  • Cannot Parse HTML Data Using Android / JSOUP
  • Why joiner is not used after Sequence generator or Update statergy
  • Java static initializers and reflection
  • unknown Exception android
  • Observable and ngFor in Angular 2
  • Unable to use reactive element in my shiny app