Determine .NET Framework version for dll
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
When you want to know which .NET Framework a DLL targets, you are really trying to identify the assembly's target framework metadata, not just the CLR version. Those are related, but they are not the same thing, and using the wrong signal can lead to incorrect compatibility assumptions.
Look for TargetFrameworkAttribute
The most direct clue is usually the assembly's TargetFrameworkAttribute. You can read it with reflection:
Typical output looks like .NETFramework,Version=v4.7.2. That is usually the answer people actually need.
CLR Metadata Is Not the Whole Story
Tools such as ILDASM or decompilers can also show the metadata runtime version, for example something like v4.0.30319. That is useful, but it does not uniquely identify the exact target framework version.
For example, many different .NET Framework versions use the CLR 4 runtime family. So:
- CLR version tells you the runtime generation,
- target framework tells you the intended framework contract.
If you need compatibility or deployment guidance, prefer the target framework value.
Use ILDASM or a Decompiler
If you do not want to write code, tools can show the same information. Open the DLL in ILDASM, ILSpy, dotPeek, or a similar decompiler and inspect the assembly metadata.
In many tools you will find either:
- the target framework attribute,
- the runtime metadata version,
- or both.
That makes GUI tools useful for one-off inspections when you are debugging a deployment issue or reviewing third-party binaries.
PowerShell Example
PowerShell can also inspect the target framework attribute:
This is handy in build scripts, deployment checks, or quick local diagnostics on Windows systems.
If you prefer a GUI path, ILSpy and similar tools often expose the same target framework information in the assembly metadata view, which is convenient when you are investigating a third-party DLL and do not want to write a helper script.
Be Careful With Modern .NET
Not every DLL targets classic .NET Framework. Some target .NET Core, .NET 5 and later, or .NET Standard. The same inspection technique still helps, but the output may look different, for example .NETStandard,Version=v2.0.
That is why the question should usually be framed as "what target framework does this assembly declare?" rather than "what .NET Framework version is this DLL?"
That wording is more precise and avoids false certainty in cases where the assembly can run in more than one compatible environment.
Common Pitfalls
- Using only the CLR metadata version and assuming it uniquely identifies the framework version.
- Confusing
.NET Frameworkwith.NET Standardor modern.NET. - Assuming every DLL will contain the same metadata pattern, especially older or unusual assemblies.
- Using file version or product version instead of target framework metadata.
- Treating the target framework as a guarantee that every runtime dependency is available on the destination machine.
Summary
- The best signal is usually the assembly's
TargetFrameworkAttribute. - CLR metadata version is informative, but it is not the same as the exact target framework.
- Reflection, PowerShell, ILDASM, and decompilers can all reveal the relevant metadata.
- Modern assemblies may target
.NET Standardor newer.NET, not classic .NET Framework. - Use target framework data for compatibility checks, not file version numbers.
Related reading
- Determine via C whether a string is a valid file path
- Determine what control the ContextMenuStrip was used on
- Developing C on Linux
- Dictionary.FirstOrDefault how to determine if a result was found
- Difference between AllowedHosts in appsettings.json and UseCors in .NET Core API 3.x
- Difference between ASP.NET Core .NET Core and ASP.NET Core .NET Framework
- Difference between ...Async and Begin... .net asynchronous APIs
- Difference between await Coroutine and await Task

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.