Assemblies
DLLs, metadata, versioning, strong names.
Assemblies in .NET: DLLs, Metadata, Versioning, and Strong Names
Level: Beginner to Intermediate
Focus: Clear concepts, real-life examples, and interview preparation
Estimated reading time: 8–10 minutes
1. What Is an Assembly?
An assembly is a compiled unit of a .NET application. It is commonly a .dll or .exe file and contains information such as type metadata, a manifest, and—when it contains managed IL—Intermediate Language (IL).
Real-life example
Think of an assembly as a packaged toolkit. The toolkit contains the tools (compiled code) and a label describing what's inside (metadata and manifest information). Another application can reference that toolkit and use its public classes and methods.
For example, a project called BillingService might compile into BillingService.dll. Another project can reference that DLL and call its public types.
Interview answer: An assembly is a compiled .NET unit of deployment and reuse, typically a DLL or EXE, containing metadata and a manifest and usually IL for managed code.
2. DLL vs. EXE
| DLL | EXE |
|---|---|
| Commonly a library referenced by another application. | Commonly an application entry point or executable host. |
| Usually isn't launched directly as a standalone application. | Typically launched as an application or host. |
Example: BillingService.dll. | Example: BillingApp.exe. |
In modern .NET, an application may run through dotnet MyApp.dll, and deployment can include app-host executables. So the filename alone does not tell the whole execution story.
3. What Is Inside an Assembly?
A managed assembly commonly includes:
- IL (Intermediate Language): Compiled instructions that the .NET runtime can JIT-compile.
- Metadata: Describes types, methods, fields, properties, references, and other code information.
- Manifest: Assembly identity and information such as its name, version, culture, referenced assemblies, and sometimes strong-name information.
- Resources: Optional embedded content such as images, text, or localized resources.
Real-life example
Imagine a medicine package:
- The medicine is like the compiled code.
- The leaflet describes what the medicine contains and how it is identified—like metadata.
- The package label identifies the product and its version—like assembly identity and manifest information.
4. Create and Use a DLL
Suppose you want to share tax calculation logic between multiple applications.
Class library (TaxCalculator.cs):
namespace FinanceLibrary;
public class TaxCalculator
{
public decimal CalculateTax(decimal amount, decimal rate)
{
return amount * rate / 100m;
}
}
Build the class library:
dotnet new classlib -n FinanceLibrary
dotnet build FinanceLibrary
The build creates a DLL under the project's output directory, for example:
FinanceLibrary/bin/Debug/<target-framework>/FinanceLibrary.dll
Another project can reference the class library:
dotnet add MyApp reference ../FinanceLibrary/FinanceLibrary.csproj
Then use its public type:
using FinanceLibrary;
var calculator = new TaxCalculator();
decimal tax = calculator.CalculateTax(1000m, 18m);
Console.WriteLine(tax); // 180
Key point: A project reference is usually preferable to manually copying a DLL because the build system tracks the dependency and builds projects in the correct order.
5. What Is Assembly Metadata?
Metadata is structured information that describes the code inside an assembly. The .NET runtime and tools use it to discover types, inspect method signatures, resolve references, and support features such as reflection.
Example:
using System;
using System.Reflection;
Type type = typeof(TaxCalculator);
Console.WriteLine(type.FullName);
foreach (var method in type.GetMethods(
BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly))
{
Console.WriteLine(method.Name);
}
This uses reflection to inspect type and method information available through metadata.
Interview distinction: Metadata describes code; IL contains instructions for managed methods. They serve different purposes.
6. Assembly Versioning
Versioning helps identify releases and manage dependencies. A traditional .NET assembly identity can include a name, version, culture, and public key token when strong-named.
A version commonly uses four parts:
Major.Minor.Build.Revision
Example: 2.4.1.0
- Major: Significant change; may indicate breaking changes.
- Minor: New functionality that is intended to remain compatible.
- Build: Build or servicing iteration.
- Revision: Smaller fix or revision.
These meanings are conventions, not automatic guarantees. Your team defines compatibility policy.
Real-life example
Think about a mobile app release:
- Version 2.0 might introduce a major redesign.
- Version 2.1 might add a feature.
- Version 2.1.1 might fix a bug.
Assembly versions similarly help identify releases, but changing a version number alone does not make code backward-compatible or incompatible.
Important: Assembly version vs. package/file version
These are not necessarily the same:
- AssemblyVersion: Part of the managed assembly identity. It can matter for assembly binding, especially in .NET Framework.
- FileVersion: Version information associated with the binary file, often used for diagnostics and display.
- Package version: The version of a NuGet package, used by package management and dependency resolution.
Do not assume that updating a NuGet package version automatically changes every assembly version in exactly the same way.
7. What Is a Strong Name?
A strong name gives an assembly a cryptographic identity using an assembly name, version, culture, and public-key information. Signing uses a key pair; the assembly carries public-key/signature information used to verify the signature.
Real-life example
A name on a parcel tells you who it claims to be from. A verified signature gives you stronger evidence that the parcel corresponds to the signer and has not been altered since signing.
A strong name is similar to a signed identity for an assembly. However, a strong name is not a substitute for a security review or a guarantee that the code is safe.
Strong names are especially relevant in .NET Framework scenarios, such as the Global Assembly Cache (GAC) and assembly identity. Modern .NET applications generally use application-local deployment and NuGet package management rather than relying on the GAC.
8. Strong-Name Signing: What to Know
Strong-name signing is commonly configured in the project build settings using a key file. The exact workflow depends on the project and SDK.
A simplified example of generating a key with a suitable SDK tool is:
sn -k MyLibrary.snk
Then configure the project to sign the assembly with that key using the appropriate build properties/tooling for your target framework and SDK. Verify the process against the tooling installed in your environment.
Interview point: Signing identifies the assembly cryptographically; it does not encrypt the assembly's IL, and it does not prove that the software is trustworthy.
9. Assembly Loading: Framework vs. Modern .NET
Assembly loading behavior depends on the runtime:
- .NET Framework: Strong-name identity, binding redirects, and the Global Assembly Cache can be important in some applications.
- Modern .NET (.NET Core and .NET 5+): Dependencies are commonly resolved from application deployment output and dependency metadata. NuGet package management and the application's deployment model are central.
Avoid saying that every .NET application resolves assemblies in exactly the same way. The runtime version and deployment type matter.
10. Common Interview Traps
- Is a DLL the same thing as an assembly? A DLL is a file extension commonly used for an assembly, but not every DLL is a .NET assembly.
- Does an assembly contain only code? No. Managed assemblies commonly contain IL, metadata, a manifest, and possibly resources.
- Is metadata the same as IL? No. Metadata describes types and members; IL contains executable intermediate instructions.
- Does changing the version guarantee compatibility? No. Compatibility depends on API and behavior changes as well as versioning policy.
- Does a strong name encrypt code? No. Strong-name signing does not encrypt IL.
- Does a strong name prove an assembly is safe? No. It provides identity/signature information, not a security audit or trust guarantee.
- Does every modern .NET application use the GAC? No. GAC usage is associated with .NET Framework; modern .NET typically deploys dependencies with the application.
11. Interview Questions and Short Answers
Q1. What is an assembly in .NET?
An assembly is a compiled .NET unit, typically a DLL or EXE, that contains metadata and a manifest and usually contains IL for managed code.
Q2. What is the difference between a DLL and an EXE?
A DLL is commonly used as a reusable library, while an EXE is commonly used to launch an application. The exact hosting model depends on the target runtime and deployment.
Q3. What is assembly metadata?
Metadata describes types, methods, properties, fields, references, and other information. The runtime and tools use it for operations such as type discovery and reflection.
Q4. What is an assembly manifest?
The manifest describes the assembly's identity and related information, including its name, version, culture, and referenced assemblies.
Q5. What is assembly versioning?
Assembly versioning identifies a release of an assembly and can affect dependency binding. A common version format is Major.Minor.Build.Revision.
Q6. What is the difference between AssemblyVersion and FileVersion?
AssemblyVersion is part of the managed assembly identity. FileVersion is file metadata commonly used for display and diagnostics. They can be set independently.
Q7. What is a strong name?
A strong name provides assembly identity information backed by a cryptographic key and signature. It is not code encryption and does not guarantee the assembly is safe.
Q8. What is the Global Assembly Cache?
The GAC is a machine-wide store for shared assemblies in .NET Framework. It is not the normal dependency deployment model for modern .NET applications.
Q9. How can one project use another project's DLL?
Reference the class library project or its assembly, then use its accessible public types. Project references are usually easier to maintain than manually copying DLLs.
Q10. What is reflection?
Reflection lets code inspect type and member information at runtime using metadata—for example, discovering the methods declared by a type.
12. Quick Revision
- Assembly: Compiled .NET unit of deployment and reuse.
- DLL / EXE: Common assembly file extensions, often used for libraries and applications respectively.
- IL: Intermediate instructions for managed methods.
- Metadata: Describes types, members, and references.
- Manifest: Describes assembly identity and related information.
- AssemblyVersion: Version component of assembly identity.
- FileVersion: File-level version information.
- Strong name: Cryptographic assembly identity/signature; not encryption or a security guarantee.
- GAC: Shared assembly store used by .NET Framework.
One-line interview summary
A .NET assembly is a compiled unit—usually a DLL or EXE—that contains metadata and a manifest, and commonly IL; versioning helps identify releases, while strong names provide cryptographically backed assembly identity rather than code encryption or a safety guarantee.
Last updated 10/19/2026
Your notes
Sign in to save personal notes on this topic — they'll sync across your devices.
Was this tutorial helpful?
Help us create more free learning resources. Learn more
