Reputation: 335
Basically what I was wondering is that when I add a reference in visual studio to any .dll file will this dll be embedded in the executable file? If not how does the executable know where to look for these dll files:
Upvotes: 1
Views: 59
Reputation: 12171
Assemblies are not embedded.
If you reference not strongly-named assembly it is copied to the folder where executable file located (also you can place assembly in any other location). CLR looks for this assembly in the folder which contains executable file or in any other folder which you can set for CLR to look for in.
If you reference any strongly-named assembly then CLR looks for this assembly by the same way as it looks for not strongly-named assembly and additionally in Global Assembly Cache (GAC - MSDN - GAC).
Upvotes: 2
Reputation: 1
Libraries can be linked to an executable in two primary ways: dynamically and statically.
Dynamically means that the executable will have a tag in the executable that declares a dependency upon a library. The operating system or run-time environment is responsible for finding that library, assuming it is installed on the system. If you are using libraries like this, you need to know where they come from (.NET, Visual Studio, 3rd party, etc...) so that you can ensure they are installed in the system when your application is distributed. In general, you can assure that you are using the version of the library you want by including it in the same folder as your executable (for Windows), but you usually don't want to do that for libraries that are likely already on the system.
Statically means the library is compiled into the executable. The executable is made to be much larger and you are guaranteed to be working with the version of the library with which you made your program, but not all libraries can be used statically.
DLL, literally, means Dynamic Link Library, so you need to know where the libraries you are using come from to ensure they are present on the system where you want your application to run.
Upvotes: 0