Answered How to use a third party dll in my project as resource

Socarsky

Well-known member
Joined
Dec 27, 2012
Messages
173
Location
Jakarta/Indonesia
Programming Experience
Beginner
I added a dll in my resources and use it like below but I think I should check it as a reference like I did before in the another project. My aim that used that dll file in my project and both parts of my project's executable file be simple one and used the dll in it that no need to copy the dll at the same folder of application, that why I want to do that.
I just found that this topic which I posted here a term of "Embedded Resource"..
dll.jpg
 
Last edited:
Certainly including it as a resource is not a viable option. Resources are for things like text and images, i.e. external data, used by the application, not parts of the applications executable code. You will need to reference that DLL in your project and set the Copy Local property of the reference to True. When you build, the EXE and the DLL will be placed in your output folder. It is then possible that you will be able to merge those two assemblies into one, although certainly not guaranteed. ILMerge is one free tool that can be used to merge assemblies. I've never used it and don't know what restrictions there might be on what you can merge but that is the first thing I'd look at.

Seriously though, people really need to get over this "I want to a single-file application" thing. The vast majority of applications require multiple files so it's unreasonable for any user to expect otherwise. Even if you can merge assemblies, you may need a separate config file anyway. Basically, you should ZIP up the files required for your app into a single archive and then the user can extract them and run them on their own machine. The fact that there may be more than one file extracted is basically irrelevant.
 
I exactly got it that you mentioned. So, now I agree with you and do that in the future. Actually I got a line of code and used it in my project to copy the dll somewhere or its ows folder, but after your point of view that no need to copy a dll file if we set it Copy Local property as True.
 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        My.Computer.FileSystem.WriteAllBytes("C:\Users\sinan\Desktop\Debug\DevComponents.DotNetBar2.Dll", My.Resources.DevComponents_DotNetBar2, False)
    End Sub

I want to learn one more thing. If I want executable file initials from StartUp of Windows then the application copies its referenced dll in StartUp then how about that fact whether it will cause a problem its exist in StartUp.
 
Back
Top