Merge DLL's
I think, many people often asked this question theirself: "How can I merge my DLL with my exe, so I can use a standalone exe file without needing the DLL file in the same folder etc...
I had the same problem just a few hours ago, and found a solution which works pretty awesome! :)
Well, this method which works like a charm.
I'll show you this in a small little tutorial :)
First we will create our own little DLL
I had the same problem just a few hours ago, and found a solution which works pretty awesome! :)
Well, this method which works like a charm.
I'll show you this in a small little tutorial :)
First we will create our own little DLL
Part 1 - Create a DLL File
So start by launching Visual Basic and create a new Project. Choose Class Library to create a new DLL file.
You get Something like this:
You get Something like this:
Code
Public Class Class1
End ClassChange the Class1 to any name you like. This will be our DLL name when using the DLL in a project.
I call it TestDLL. So it should now look similar to this:
I call it TestDLL. So it should now look similar to this:
[img]http://s1.directupload.net/images/130919/we2ves46.png[/img]
Now we create to little functions, so our DLL can do some stuff.
First, I create a Public Function which returns the computername, and second I create a Public Function which returns the Operating System name. Of course you can add whatever you like your DLL be able to do. You can also just use other .Net DLLs, downloaded from the web.
This should now look like this:
First, I create a Public Function which returns the computername, and second I create a Public Function which returns the Operating System name. Of course you can add whatever you like your DLL be able to do. You can also just use other .Net DLLs, downloaded from the web.
This should now look like this:
[img]http://s7.directupload.net/images/130919/jhyxlul6.png[/img]
Then compile the DLL. It will now created inside the Debug folder of your project.
Part 2 - Create Main Application
Now we are going to create our Main program which requires the DLL file. We will remove the Depencies from this Application and merge the DLL and the executable together.
But calm down and go step by step ^^
So, Start by creating a new Windows Form Application.
Just add Two Buttons and Title one of the "Computername" and the second one "Operating System".
This should now look like this:
But calm down and go step by step ^^
So, Start by creating a new Windows Form Application.
Just add Two Buttons and Title one of the "Computername" and the second one "Operating System".
This should now look like this:
[img]http://s1.directupload.net/images/130919/nof37tvc.png[/img]
Now go to Project >> Add Reference and search our TestDLL.dll on your computer. Then you add it as reference.
Till now its just like we use it normally.
Now type at the top of your Code:
Till now its just like we use it normally.
Now type at the top of your Code:
Code
Imports TestDLLNow below the Public Class Form1 we are going to type:
Code
Dim MyDLL As New TestDLL.TestDLLNow just doubleclick the first and second button and call the functions of the dll file:
[img]http://s7.directupload.net/images/130919/n6zw7hpn.png[/img]
Part 3 - Add DLL as Ressource and merge it with Main Application
Now we are going to do the most important part. We remove the depencies by merging the DLL with the Main Application as a Ressource File.
Go To My Project in The Project Explorer.
Go to the Ressource Tab.
Add your TestDLL.dll as a ressource file.
Now go to the Application Tab and Click on Application Events.
You will get something like this (in your native language of course):
Go To My Project in The Project Explorer.
Go to the Ressource Tab.
Add your TestDLL.dll as a ressource file.
Now go to the Application Tab and Click on Application Events.
You will get something like this (in your native language of course):
[img]http://s14.directupload.net/images/130919/n9hzhur3.png[/img]
Now inside the Partial Friiend Class MyApplication you are going to paste this code:
Code
Partial Friend Class MyApplication
Private WithEvents DLLDomain As AppDomain = AppDomain.CurrentDomain
Private Function DLL_AssemblyResolve(ByVal sender As Object, ByVal args As System.ResolveEventArgs) As System.Reflection.Assembly Handles DLLDomain.AssemblyResolve
If args.Name.Contains("TestDLL") Then
Return System.Reflection.Assembly.Load(My.Resources.TestDLL)
Else
Return Nothing
End If
End Function
End ClassYou basiclly paste the name of TestDLL (or whatever DLL you like to merge) without the .dll at the end in the right places.
After this is done, you are finished with this, we are done!!
Compile your Application and you can use it as a standalone exe file.
You don't need the DLL file to be with your App.
Whenever you use it, the App will automaticlly use it from the ressources without extracting it.
This can be used for Rat Servers if they need DLL's or just If you are to lazy to get two files.
Everything compact in one executable!!
I hope u liked the Tutorial :)
After this is done, you are finished with this, we are done!!
Compile your Application and you can use it as a standalone exe file.
You don't need the DLL file to be with your App.
Whenever you use it, the App will automaticlly use it from the ressources without extracting it.
This can be used for Rat Servers if they need DLL's or just If you are to lazy to get two files.
Everything compact in one executable!!
This will only work with .net DLL's.
C++ DLL's are not working with this method!
C++ DLL's are not working with this method!
I hope u liked the Tutorial :)


