Sascha
Sascha

Reputation: 2213

How can I find out if .NET 4.02 is installed?

I've asked this question yesterday - it was closed as "exact duplicate" by some people who didn't take the time themselves to read questions / comments carefully! So, another try - maybe it gets the time to receive some working answer before being closed for some pointless reason again.

Microsoft has recently released some "update" for .NET Framework. Unfortunately, I don't know any way to find out which version is installed. Framework-Version stays on 4.0.30319.239.

Thanks for some enlightement ;-)

PS: Setting supportedRuntime in app.config to Version=4.0.2 makes the application tell me at startup that 4.0.2 is not installed (in no time - so there must be some place where the "real" version can be found).

Upvotes: 8

Views: 4282

Answers (3)

springy76
springy76

Reputation: 3786

Have a look at:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319\SKUs

If you have installed 4.0.2 then there exist these additional nodes:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319\SKUs\.NETFramework,Version=v4.0.1
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319\SKUs\.NETFramework,Version=v4.0.1,Profile=Client
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319\SKUs\.NETFramework,Version=v4.0.2
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319\SKUs\.NETFramework,Version=v4.0.2,Profile=Client

Upvotes: 13

Uwe Keim
Uwe Keim

Reputation: 40736

Let's give it a try:

If you know a special function/method inside a class that is only present in .NET 4.02 but not in .NET 4.0, I would use reflection to e.g. get a list of all methods of a class or the signature of a specific method.

If there are only internal (methods/properties) changes, you could use ILSpy to search for such changes and then use again reflection to check for the changes.

On the other hand, I'm not sure whether some security constraints might hinder you from doing reflection.

Upvotes: 1

Matthew Abbott
Matthew Abbott

Reputation: 61589

This shouldn't make a difference. You don't target specific build numbers of the framework, you target the release number, which in this case is 4.0. What are you doing where you need to know the exact build number?

WTF - why use buildcounters?!

Why wouldn't you? It details the exact version of the framework. Typically you don't release software with a round "this is version 1.0.0.0" because it can cause havoc with versioning for updates/hotfixes etc.

Simply targeting .NET 4.0 should be sufficient.

Upvotes: 1

Related Questions