Understanding DLLs and How They Work in Visual Studio

Does anyone have a good resource in dll and how are they used / generated in Visual Studio? A few questions that I'm pretty vague about are:

  • How to update files.
  • How DLL version numbers are generated
  • The difference between adding a project link and viewing for a specific DLL

Any other tips are also welcome.

+6
dll visual-studio
source share
2 answers

.NET DLL

The general term for a .NET DLL is assembly. They represent a single atomic deployment unit and consist of one or more CLR modules (for most developers, usually only one if they do not combine the compiler with two or more languages, for example). Assemblies contain CIL code and CLR metadata, such as an assembly manifest.

.refresh Files

.refresh files are simply text files that tell VS where to check new builds of reference dlls. They are used in web file projects where there is no project file to store this information.

Version numbers

.NET assembly version numbers are generated by the AssemblyVersion attribute, which is usually found in the source file named "AssemblyInfo.cs" (found in the project folder named "Properties" from VS2005 onwards). Version numbers consist of a file major.minor.build.revision, for example -

[assembly: AssemblyVersion ("1.0.0.0")]

AssemblyVersion is used as part of the assembly identifier (that is, in its strong name) and plays an important role in the binding process and in versioning policy decisions.

For example, if I had two assemblies with the same name in the GAC, then the AssemblyVersion attribute will distinguish them to load a specific version of the assembly.

The AssemblyVersion number can be fixed and increased manually, or you can let the compiler generate assembly and revision numbers for you by specifying:

[assembly: AssemblyVersion ("1.0. * ")] - generates the assembly and revision number
[assembly: AssemblyVersion ("1.0.0. * ")] - generates a version number

If the AssemblyVersion attribute is missing, the default version number is "0.0.0.0".

The value of the AssemblyVersion attribute becomes part of the assembly manifest; the value of the AssemblyFileVersion attribute is not equal.

The AssemblyFileVersion attribute is used to embed a version of a Win32 file in a DLL. If not, AssemblyVersion is used. It has nothing to do with how the .NET assembly assembler / resolver chooses which version of the assembly to load.

Link to project and view for DLL

If you add a link to the project, this means that the specified project will be part of your decision. This makes debugging easier if you can go directly to the specified project code. If you just add a link to the dll, then you do not have the advantages of a project that is part of the solution, and the ability to enter code into the solution.

+10
source share

See the question about DLL info for some background.

Version numbers for unmanaged DLLs are stored in the DLL file, as well as for exe. For managed DLLs, I believe that it uses the AssemblyFileInfo attribute, usually in AssemblyInfo.cs for a generated Visual Studio project:

 [assembly: AssemblyFileVersion("1.0.0.0")] 

If you add a link for the project, then VS will be able to copy the correct flavor (debug / release) of the link assembly to your output directory. He can also use this information to implicitly add dependency between projects so that it is built in the correct order.

+5
source share

All Articles