Click here to Skip to main content
15,881,204 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm relatively not new to Vb.net but this is my first time dealing with .dll files.

Okay... Yes... Whatever, I am a noob ._.

So I'm using a DotNetZip .dll file and I want it to extract files (which works really fine)

But obviously you have to either merge the .dll with the .exe, or you have to install the .dll onto the computer of the person who you are planning to share the program with.

I tried merging the files, but I personally don't like the method itself and would like to find out how to install the .dll onto the persons PC.

Right now I'm thinking to install the .dll into Programfiles\(foldername)\dotnetzip.dll

Using Special Folder Environment ect.

But my actual question is... How do I get my program to check in program files for the .dll and use it?

I noticed it works ONLY if the .dll is in the same exact folder with the .exe :(

Is there a way to change that?

Thank you guys. Have a very nice weekend :)
Posted
Comments
dimaba10000 1-Aug-14 18:50pm    
*bump*
Can someone help :( ?
Sergey Alexandrovich Kryukov 1-Aug-14 21:51pm    
Are you serious? How about some patience?
—SA
dimaba10000 2-Aug-14 1:03am    
I am sorry :( I'm still pretty new the forums...

Спасибо!
Thank You!
Sergey Alexandrovich Kryukov 2-Aug-14 1:22am    
No problem at all; and you are very welcome. I would just say that it was Friday evening, not very active time, and you waiting just view hours. There is no any certain wait time for answering or any rules about that. It's not unusual that some questions are answered in few minutes, but it's also not unusual that some are never answered, or answered after many days...

Good luck, call again; we'll gladly try to help.

—SA

First of all, the distinction between .EXE and .DLL is not really significant in .NET. The central notion is assembly. These files are only the PE files used as assembly modules. An assembly can have more than one module, but Visual Studio projects usually support only one, which is not a big defect. Please see:
http://en.wikipedia.org/wiki/Portable_Executable[^],
http://msdn.microsoft.com/en-us/library/58scf68s.aspx[^],
http://msdn.microsoft.com/en-us/library/system.reflection.assembly.getmodule%28v=vs.110%29.aspx[^] (advanced, please see below).

The .EXE files can be used as the application as they have the entry point which the platform knows, and DLL can be used as a type library, but EXE can be used as a library in exactly the same way.

The library assemblies doesn't have to "checked in". One assembly can reference other assemblies (with Visual Studio, see Solution Explorer's "Reference", "Add Reference") and the use them exactly as it was in the same assembly, for the types and members marked by access modifiers public or protected. Alternatively, an assembly can be loaded using System.Reflection.Assembly methods. Please see:
http://msdn.microsoft.com/en-us/library/ms973231.aspx[^],
http://msdn.microsoft.com/en-us/library/system.reflection.assembly%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/ms173121.aspx[^],
http://msdn.microsoft.com/en-us/library/wxh6fsc7.aspx[^].

—SA
 
Share this answer
 
Comments
Abhinav S 2-Aug-14 0:51am    
5!
Sergey Alexandrovich Kryukov 2-Aug-14 1:18am    
Thank you, Abhinav.
—SA
dimaba10000 4-Aug-14 3:16am    
Well, you defiantly have a point here! But you are throwing so much information at me at the same time... I can't really understand where to start from. My original question was, if it was possible to get my executable application to check for .dll files in a specific folder on the users computer, to use that .dll file as a reference. Since I don't want to keep both .dll and .exe in the same folder.

Here is something I'm thinking of doing:

I will keep the .dll inside the Resources folder, once the .exe will be executed, it will copy the .dll into ProgramFiles or Temp or even AppData (just anything). Then the program will look in that folder for the .dll and use it as a reference (DotNetZip) to be able to extract files I need.

I thank you very much!
Sergey Alexandrovich Kryukov 4-Aug-14 10:59am    
I'm throwing all this information because your question requires that. You really need to understand all these things.

As to your more particular question, I gave you two particular suggestions in Solution 3. Please see.
Are you going to accept Solution 1 and 3 (green "Accept" button)? In all cases, your follow-up questions will be welcome.

—SA
To deploy dlls with exe's together, you can create a deployment project that will help you create an automated setup process.
Try
Video Tutorial 1[^]
Adding a Setup Wizard[^]
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 2-Aug-14 1:18am    
Understanding setup is good, but I think this is pretty much irrelevant to the question. Installation is only needed with more complex setting, when, say, register is modified to register file types to be opened with the application, or something else, and when desinstallation/cleanup is important.

I am very satisfied with the fact that more and more applications not requiring installation are published, and that Microsoft people started to encourage installation by copy, without using the installer. Moreover, some Microsoft people admitted that the idea of creating of global system registry was pretty bad.

—SA
dimaba10000 wrote:
My original question was, if it was possible to get my executable application to check for .dll files in a specific folder on the users computer, to use that .dll file as a reference. Since I don't want to keep both .dll and .exe in the same folder.
You again misunderstood. There is not such thing as "check". Well, you can "check" by using something like Directory.GetFiles, but this can be useful if you want to load some assemblies during runtime and use reflection. I don't think this is what you want, you mentioned "reference" (and I'm not sure is you are ready).

When you reference assemblies, this is a different story: assemblies are referenced by the names of some PE files (your "DLLs") by name, or they can be referenced by strong names, and found in some directories (or in GAC). So, first and foremost, my best advice would be: forget about your "I don't want to keep both .dll and .exe in the same folder" and… actually put them in the same folder. Pay attention on how your solution is built: even if your output paths are different for different projects (which is not very good; I always advise to put all output in the same directory; this is not done this way by default just because Visual Studio cannot do it automatically; and everything is designed to work immediately after your reference your projects by other projects), Visual Studio copies all the referenced DLLs where the application is.

I can see only one case when you want to put some library assemblies in some separate directory
: when you have more than one product using those library assemblies; and when those products don't have to be installed at the same time, and when you don't want to put your libraries in GAC. In this, case, one of the possible techniques would be using config file with assemblyBinding element.

For example, let's assume you create some directories in different places, and some directory where your library files are. Suppose you put some application assembly, one of your products in some other directory (in my example shown below it could be the directory on the same level called "MyLibrary", but it could be any relative path, relative to you application assembly file). You can add a configuration file to your assembly file; it it's name is "myApplication.exe", if should be "myApplication.exe.config". In this file you can write, for example:
HTML
<configuration>
	<runtime>
		<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
			<probing privatePath="..\MyLibrary"/>
		</assemblyBinding>
	</runtime>
</configuration>

It will allow "myApplication.exe" to search for assembly files referenced by name in "MyLibrary", more exactly, add this path in search.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900