Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use an DLL load from Embed Resource?
    primarykey
    data
    text
    <p>I have a DLL >> <em>System.Data.SQLite.dll</em></p> <p>To use it in a normal way > just add it as reference and</p> <pre><code>using System.Data.SQLite; </code></pre> <p>then, I can use all the functions inside this DLL.</p> <p><strong>But</strong>, I want to merge my <strong><em>app.exe</em></strong> and this DLL into one single file. I have tried using <strong>ILmerge</strong>, but fail. As I know, <strong>ILmerge</strong> cannot merge unmanage DLL.</p> <p>So, I tried another method > make the DLL as embbed resource. I am able to load it as an assembly with the below code:</p> <pre><code>Stream stm = Assembly.GetExecutingAssembly().GetManifestResourceStream("MyApp.System.Data.SQLite.dll"); byte[] ba = null; byte[] buffer = new byte[16 * 1024]; using (MemoryStream ms = new MemoryStream()) { int read; while ((read = stm.Read(buffer, 0, buffer.Length)) &gt; 0) { ms.Write(buffer, 0, read); } ba = ms.ToArray(); } Assembly sSQLiteDLL = Assembly.Load(ba); </code></pre> <p>but, how am I going to use the functions in SQLiteDLL?</p> <p>I also tried add the DLL as resource in properties and load it like this:</p> <pre><code>public Form1() { AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); InitializeComponent(); } System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { AppDomain domain = (AppDomain)sender; if (args.Name.Contains("System_Data_SQLite")) { return domain.Load(MyApp.Properties.Resources.System_Data_SQLite); } return null; } </code></pre> <p>The above explained what I've got so far and I don't know what to do next to use the DLL? I still can't use the functions inside the DLL.</p> <p>For example, when I type this:</p> <pre><code>SQLiteCommand cmd = new SQLiteCommand(); </code></pre> <p>The Visual Studio says:</p> <p><em>Error 21 The type or namespace name 'SQLiteCommand' could not be found (are you missing a using directive or an assembly reference?)</em></p> <p>Can you share your insight? Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload