开发者

How do I check the .NET version of an App?

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?


.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.


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


If you open the app in Visual Studio:

  1. Right click the app project
  2. Select 'Properties'
  3. Select 'Application'

How do I check the .NET version of an App?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜