Other than running it on a computer that only has .NET Framework Version 3.5, how do I check what version a .NET app is?
-
2Do you mean "how do I detect what version of the .NET framework that an application is targetting?" – David_001 Jul 03 '10 at 20:29
5 Answers
.NET framework versioning went foobar after .NET 2.0. An app targets a CLR version, it does so with the assembly metadata for the EXE. And there are currently four of them, 1.0, 1.1, 2.0 and 4.0. Not counting special ones like used by the Compact Framework, Silverlight, Micro Framework.
Framework versions 2.0, 2.0SP1, 2.0SP2, 3.0, 3.5 and 3.5SP1 all target the same CLR version, 2.0.50727. What's different between these releases is that they have additional assemblies available in later versions. The kind that support features like WPF, WCF and LINQ. They are additive, just more goodies added to something that was already pretty solid. You never really have to guess what version of the framework your program needs, just open the References node in the Solution Explorer window and look at the assembly version numbers. Or set the Target Framework property in your project and work your way up until the compiler stops complaining.
Back to your original question: the version you give your own .NET app is entirely up to you. Edit the [AssemblyVersion] attribute in the AssemblyInfo.cs file.

- 922,412
- 146
- 1,693
- 2,536
I'm not sure to understand your question.
If you want to check what version of the .NET framework is installed from a .NET application, check this:
http://geekswithblogs.net/lorint/archive/2006/01/30/67654.aspx
-
3He wants to know how you determine which version of the .NET framework an app is built against or dependent on. – Jason Jul 03 '10 at 20:31
-
2http://stackoverflow.com/questions/325918/how-to-find-out-which-version-of-net-framework-executable-needs-to-run then ? – Jul 03 '10 at 20:39
-
Accepted for Pierre link. IL disasm comes with VS and accepted solution is easy enough to use. – Jul 03 '10 at 23:59
If you open the app in Visual Studio:
- Right click the app project
- Select 'Properties'
- Select 'Application'

- 3,584
- 4
- 23
- 53

- 21
- 2
Reflector will tell you which framework version an assembly was built with. Open up each assembly in Reflector, open up the "References" and check the version shown for mscorlib and other system assemblies.
If reflector can do it, it must be possible to work it out in code, at least in principle. It looks like Reflector uses Cecil to inspect code.

- 5,176
- 6
- 65
- 87
-
Reflector will tell you which main *CLR* version is being used, and the version of assemblies currently being *loaded*, but that's kinda different from a program being built against (and requiring at minimum) those versions. Idk about Cecil which is a chore to install, but I found out looking for the `NETFramework,Version` string inside an .exe gives you a far more accurate ballpark (sometimes though I guess it could even happen that an Y target version is still eventually fine using X version dlls) – mirh Nov 28 '20 at 13:32
As far as I know this is not possible from within code. A dll does not target a specific framework version, instead it runs under a particular CLR and uses particular assemblies.
For example, you could define a 3.0 app as one that runs under the 2.0 CLR, and uses assemblies that were released when .NET 3.0 was released. (You'd also need to check that it doesn't reference any assemblies that were released when 3.5 or 4.0 were released - even though these newer assemblies might only reference other assemblies that were released with version 2.0).#
Realistically, the only way to do this would be to have a list off all assemblies released with a particular framework version, and do a cross-check of the assembly-under-test with this list.

- 5,703
- 4
- 29
- 55