Skip to content
</> Mücahit TopalA developer's notebook

Blog/C#

Merging an exe and a dll

Mücahit Topal 1 min read 5,065 views TREN

First, let's add the dll file to be merged to the project 

Next, let's mark it as Build Action = Embedded Resource

Let's edit the Program.cs file as shown below.

using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Reflection;

namespace exe_dll_birleştir
{
    static class Program
    {
        /// 

/// The main entry point for the application. ///

[STAThread] static void Main() { AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { String resourceName = "exe_dll_birleştir." + new AssemblyName(args.Name).Name + ".dll"; using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName)) { Byte[] assemblyData = new Byte[stream.Length]; stream.Read(assemblyData, 0, assemblyData.Length); return Assembly.Load(assemblyData); } } } }

 

 

,,,

Share X Facebook LinkedIn WhatsApp

More from this category

Comments 0

No comments yet.

Leave a comment

Comments appear after approval.