Click here to Skip to main content
15,891,976 members
Articles / Programming Languages / C#

Load DLL From Embedded Resource

Rate me:
Please Sign up or sign in to vote.
4.90/5 (114 votes)
22 Mar 2015CPOL6 min read 529.5K   17.6K   266  
Merge DLL with App Into Single EXE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Reflection;

namespace WindowsFormsApplication24
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            EmbeddedAssembly.Load("WindowsFormsApplication24.System.Data.SQLite.dll", "System.Data.SQLite.dll");
            EmbeddedAssembly.Load("WindowsFormsApplication24.System.Windows.Forms.Ribbon35.dll", "System.Windows.Forms.Ribbon35.dll");

            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }

        static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
        {
            Assembly asm = EmbeddedAssembly.Get(args.Name);
            return asm;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Other Other
Programming is an art.

Comments and Discussions