c# Embed Resource dll

1

I have a function that need a dll Resource

    using (SQLiteConnection c = new SQLiteConnection("Data Source=logindata;Version=3;"))
    {
    }

it requires : SQLite.Interop.dll

so instead of putting that dll in the same Enviroment folder i use it as an embedded resource :

   [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
            Application.Run(new Form1());
        }

        private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
        {
            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("EmbedAssembly.SQLite.Interop.dll"))
            {
                byte[] Data = new byte[stream.Length];
                stream.Read(Data, 0, Data.Length);
                return Assembly.Load(Data);

            }
        }

But it still throw an exception :

Unable to load DLL 'SQLite.Interop.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

EDIT : Solved by adding the whole new class to the project instead of refering to it as a dll reference

c#
sqlite
dll
asked on Stack Overflow Oct 6, 2016 by Left panda • edited Oct 18, 2016 by Left panda

1 Answer

0

Solved by adding the whole new Sqlite Class to my project instead of adding it on my project as a reference .

answered on Stack Overflow Oct 18, 2016 by Left panda • edited Jan 25, 2018 by Left panda

User contributions licensed under CC BY-SA 3.0