Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to declare type in an Imported or Embed Resource DLL
    primarykey
    data
    text
    <p>I'm actually looking for solution merge all DLL and EXE into single file.</p> <p>I have asked a question at here:</p> <blockquote> <blockquote> <p><a href="https://stackoverflow.com/questions/9228423/how-to-use-an-dll-load-from-embed-resource">How to use an DLL load from Embed Resource?</a></p> </blockquote> </blockquote> <p>and I received suggestion that I can link the DLL as embed resource, then write the embed DLL file into memory and use DLLImport to import the DLL.</p> <p>I followed the instructions here:</p> <blockquote> <blockquote> <p><a href="http://weblogs.asp.net/ralfw/archive/2007/02/04/single-assembly-deployment-of-managed-and-unmanaged-code.aspx" rel="nofollow noreferrer">http://weblogs.asp.net/ralfw/archive/2007/02/04/single-assembly-deployment-of-managed-and-unmanaged-code.aspx</a></p> </blockquote> </blockquote> <p>and below is what I have done:</p> <pre><code>[DllImport("System.Data.SQLite.dll")] public static SQLiteConnection sqLiteConnection1 = new SQLiteConnection(); public Form1() { ResourceExtractor.ExtractResourceToFile("MyApp.System.Data.SQLite.dll", "System.Data.SQLite.dll"); } public static class ResourceExtractor { public static void ExtractResourceToFile(string resourceName, string filename) { if (!System.IO.File.Exists(filename)) using (System.IO.Stream s = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName)) using (System.IO.FileStream fs = new System.IO.FileStream(filename, System.IO.FileMode.Create)) { byte[] b = new byte[s.Length]; s.Read(b, 0, b.Length); fs.Write(b, 0, b.Length); } } } </code></pre> <p>but Visual Studio says that this block creates an error:</p> <pre><code>[DllImport("System.Data.SQLite.dll")] public static SQLiteConnection sqLiteConnection1 = new SQLiteConnection(); </code></pre> <p><em>Error 1 Attribute 'DllImport' is not valid on this declaration type. It is only valid on 'method' declarations.</em></p> <p>How to declare the type inside that DLL?</p> <p>Thanks you very much.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    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