Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7439537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:43:13+00:00 2026-05-29T10:43:13+00:00

I’m actually looking for solution merge all DLL and EXE into single file. I

  • 0

I’m actually looking for solution merge all DLL and EXE into single file.

I have asked a question at here:

How to use an DLL load from Embed Resource?

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.

I followed the instructions here:

http://weblogs.asp.net/ralfw/archive/2007/02/04/single-assembly-deployment-of-managed-and-unmanaged-code.aspx

and below is what I have done:

[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);
        }
    }
}

but Visual Studio says that this block creates an error:

[DllImport("System.Data.SQLite.dll")]
public static SQLiteConnection sqLiteConnection1 = new SQLiteConnection();

Error 1 Attribute ‘DllImport’ is not valid on this declaration type. It is only valid on ‘method’ declarations.

How to declare the type inside that DLL?

Thanks you very much.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T10:43:14+00:00Added an answer on May 29, 2026 at 10:43 am

    DllImport is only for native DLLs.

    On embedding managed DLLs you have several options:

    • use ILMerge (free)
      For howto see here and here

    OR

    • use some tool like SmartAssembly (commercial)
      it can embed and merge among other things (no need to change your source code)

    OR

    • code that yourself in less than 10 lines (free but minimal source code change)
      mark all needed dependencies as “embedded resource” – this way they are included in the EXE file… you need to setup an AssemblyResolve handler which at runtime reads from Resources and returns the needed DLLs to the .NET runtime…

    On using a type from such an Assembly see these links (they including reference material AND some sample code etc.):

    • http://msdn.microsoft.com/en-us/library/system.activator.createinstance.aspx
    • https://stackoverflow.com/a/57450/847363
    • http://msdn.microsoft.com/en-us/library/h538bck7.aspx (loads an ssembly from a byte array so there is no need to write that assembly to the filesystem)
    • http://msdn.microsoft.com/en-us/library/system.reflection.assembly.gettype.aspx
    • http://www.codeproject.com/Articles/32828/Using-Reflection-to-load-unreferenced-assemblies-a
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I have a text area in my form which accepts all possible characters from
I have a reasonable size flat file database of text documents mostly saved in
I want use html5's new tag to play a wav file (currently only supported
I am currently running into a problem where an element is coming back from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.