Microsoft Net Framework 4.5.2 Mac
In.NET Framework 4.5.2 and earlier versions, this method would throw if true was passed for the verbose parameter and there were certificates installed that weren't supported by the.NET Framework. Now, the method will succeed and return a valid string that omits the inaccessible portions of the certificate.
- The Microsoft.NET Framework 4.5.2 is a highly compatible, in-place update to the Microsoft.NET Framework 4, Microsoft.NET Framework 4.5 and Microsoft.NET Framework 4.5.1. The web installer is a small package that automatically determines and downloads only the components applicable for a particular platform.
- This issue has been fixed in the.NET Framework 4.5.2 and may be addressed by upgrading to that version (or a later version) of the.NET Framework. Alternatively, users can still drag scroll bars to the final items in these collections, but may need to try twice to do so successfully.
- Apr 17, 2018 However, this update is not offered together with the.NET Framework 4.5.2 recommended update that is described previously. Computers that meet the following criteria will receive this update: The.NET Framework 4.5.2 is already installed. There is no previous.NET Framework 4,.NET Framework 4.5, or.NET Framework 4.5.1 language pack installed.
- The Microsoft.NET Framework 4.5.2 is a highly compatible, in-place update to the Microsoft.NET Framework 4, Microsoft.NET Framework 4.5 and Microsoft.NET Framework 4.5.1.
- Microsoft net framework 4 5 2 free download - Microsoft.NET Framework 4.5, Microsoft.NET Framework 4, Microsoft.NET Framework 4.5.2, and many more programs.
- Oct 09, 2012 The.NET Framework 4.5 is a highly compatible, in-place update to the.NET Framework 4. By using the.NET Framework 4.5 together with the C#, Visual Basic, or F# programming language, you can write Windows apps.
If you are migrating from the .NET Framework 4.5 to 4.5.2, review the following topics for application compatibility issues that may affect your app:
ADO.NET
ADO.NET now attempts to automatically reconnect broken SQL connections
Details | Beginning in the .NET Framework 4.5.1, the .NET Framework will attempt to automatically reconnect broken SQL connections. Although this will typically make apps more reliable, there are edge cases in which an app needs to know that the connection was lost so that it can take some action upon reconnection. |
Suggestion | If this feature is undesirable due to compatibility concerns, it can be disabled by setting the ConnectRetryCount property of a connection string (or SqlConnectionStringBuilder) to 0. |
Scope | Edge |
Version | 4.5.1 |
Type | Runtime |
Affected APIs |
ASP.NET
ASP.NET MVC now escapes spaces in strings passed in via route parameters
Details | In order to conform to RFC 2396, spaces in route paths are now escaped when populating action parameters from a route. So, whereas /controller/action/some data would previously match the route /controller/action/{data} and provide some data as the data parameter, it will now provide some%20data instead. |
Suggestion | Code should be updated to unescape string parameters from a route. If the original URI is needed, it can be accessed with the RequestUri.OriginalString API. |
Scope | Minor |
Version | 4.5.2 |
Type | Runtime |
Affected APIs |
No longer able to set EnableViewStateMac to false
Details | ASP.NET no longer allows developers to specify <pages enableViewStateMac='false'/> or <@Page EnableViewStateMac='false' %> . The view state message authentication code (MAC) is now enforced for all requests with embedded view state. Only apps that explicitly set the EnableViewStateMac property to false are affected. |
Suggestion | EnableViewStateMac must be assumed to be true, and any resulting MAC errors must be resolved (as explained in this guidance, which contains multiple resolutions depending on the specifics of what is causing MAC errors). |
Scope | Major |
Version | 4.5.2 |
Type | Runtime |
Profiling ASP.Net MVC4 apps can lead to Fatal Execution Engine Error
Details | Profilers using NGEN /Profile assemblies may crash profiled ASP.NET MVC4 applications on startup with a 'Fatal Execution Engine Exception' |
Suggestion | This issue is fixed in the .NET Framework 4.5.2. Alternatively, the profiler may avoid this issue by specifying COR_PRF_DISABLE_ALL_NGEN_IMAGES in its event mask. |
Scope | Edge |
Version | 4.5 |
Type | Runtime |
Core
A ConcurrentDictionary serialized in .NET Framework 4.5 with NetDataContractSerializer cannot be deserialized by .NET Framework 4.5.1 or 4.5.2
Details | Due to internal changes to the type, ConcurrentDictionary<TKey,TValue> objects that are serialized with the .NET Framework 4.5 using the NetDataContractSerializer cannot be deserialized in the .NET Framework 4.5.1 or in the .NET Framework 4.5.2.Note that moving in the other direction (serializing with the .NET Framework 4.5.x and deserializing with the .NET Framework 4.5) works. Similarly, all 4.x cross-version serialization works with the .NET Framework 4.6.Serializing and deserializing with a single version of the .NET Framework is not affected. |
Suggestion | If it is necessary to serialize and deserialize a ConcurrentDictionary<TKey,TValue> between the .NET Framework 4.5 and .NET Framework 4.5.1/4.5.2, an alternate serializer like the DataContractSerializer or BinaryFormatter serializer should be used instead of the NetDataContractSerializer.Alternatively, because this issue is addressed in the .NET Framework 4.6, it may be solved by upgrading to that version of the .NET Framework. |
Scope | Minor |
Version | 4.5.1 |
Type | Runtime |
ConcurrentQueue<T>.TryPeek can return an erroneous null via its out parameter
Details | In some multi-threaded scenarios, TryPeek(T) can return true, but populate the out parameter with a null value (instead of the correct, peeked value). |
Suggestion | This issue is fixed in the .NET Framework 4.5.1. Upgrading to that Framework will solve the issue. |
Scope | Major |
Version | 4.5 |
Type | Runtime |
Affected APIs |
COR_PRF_GC_ROOT_HANDLEs are not being enumerated by profilers
Details | In the .NET Framework v4.5.1, the profiling API RootReferences2() is incorrectly never returning COR_PRF_GC_ROOT_HANDLE (they are returned as COR_PRF_GC_ROOT_OTHER instead). This issue is fixed beginning in the .NET Framework 4.6. |
Suggestion | This issue has been fixed in the .NET Framework 4.6 and may be addressed by upgrading to that version of the .NET Framework. |
Scope | Minor |
Version | 4.5.1 |
Type | Runtime |
Deserialization of objects across appdomains can fail
Details | In some cases, when an app uses two or more app domains with different application bases, trying to deserialize objects in the logical call context across app domains throws an exception. |
Suggestion | See Mitigation: Deserialization of Objects Across App Domains |
Scope | Edge |
Version | 4.5.1 |
Type | Runtime |
EventListener truncates strings with embedded nulls
Details | EventListener truncates strings with embedded nulls. Null characters are not supported by the EventSource class. The change only affects apps that use EventListener to read EventSource data in process and that use null characters as delimiters. |
Suggestion | EventSource data should be updated, if possible, to not use embedded null characters. |
Scope | Edge |
Version | 4.5.1 |
Type | Runtime |
Affected APIs |
EventSource.WriteEvent impls must pass WriteEvent the same parameters that it received (plus ID)
Details | The runtime now enforces the contract that specifies the following: A class derived from EventSource that defines an ETW event method must call the base class EventSource.WriteEvent method with the event ID followed by the same arguments that the ETW event method was passed. |
Suggestion | An IndexOutOfRangeException exception is thrown if an EventListener reads EventSource data in process for an event source that violates this contract. |
Scope | Minor |
Version | 4.5.1 |
Type | Runtime |
Marshal.SizeOf and Marshal.PtrToStructure overloads break dynamic code
Details | Beginning in the .NET Framework 4.5.1, dynamically binding to the methods SizeOf<T>(), SizeOf<T>(T), PtrToStructure(IntPtr, Object), PtrToStructure(IntPtr, Type), PtrToStructure<T>(IntPtr), or PtrToStructure<T>(IntPtr, T), (via Windows PowerShell, IronPython, or the C# dynamic keyword, for example) can result in MethodInvocationExceptions because new overloads of these methods have been added that may be ambiguous to the scripting engines. |
Suggestion | Update scripts to clearly indicate which overload should be used. This can typically done by explicitly casting the methods' type parameters as Type. See this link for more detail and examples of how to workaround the issue. |
Scope | Minor |
Version | 4.5.1 |
Type | Runtime |
Some .NET APIs cause first chance (handled) EntryPointNotFoundExceptions
Details | In the .NET Framework 4.5, a small number of .NET methods began throwing first chance EntryPointNotFoundExceptions. These exceptions were handled within the .NET Framework, but could break test automation that did not expect the first chance exceptions. These same APIs break some ApiVerifier scenarios when HighVersionLie is enabled. |
Suggestion | This bug can be avoided by upgrading to .NET Framework 4.5.1. Alternatively, test automation can be updated to not break on first-chance EntryPointNotFoundExceptions. |
Scope | Edge |
Version | 4.5 |
Type | Runtime |
Affected APIs |
WinRT stream adapters no long call FlushAsync automatically on close
Details | In Windows Store apps, Windows Runtime stream adapters no longer call the FlushAsync method from the Dispose method. |
Suggestion | This change should be transparent. Developers can restore the previous behavior by writing code like this: |
Scope | Transparent |
Version | 4.5.1 |
Type | Runtime |
Data
ADO.NET now attempts to automatically reconnect broken SQL connections
Details | Beginning in the .NET Framework 4.5.1, the .NET Framework will attempt to automatically reconnect broken SQL connections. Although this will typically make apps more reliable, there are edge cases in which an app needs to know that the connection was lost so that it can take some action upon reconnection. |
Suggestion | If this feature is undesirable due to compatibility concerns, it can be disabled by setting the ConnectRetryCount property of a connection string (or SqlConnectionStringBuilder) to 0. |
Scope | Edge |
Version | 4.5.1 |
Type | Runtime |
Affected APIs |
SqlConnection.Open fails on Windows 7 with non-IFS Winsock BSP or LSP present
Details | Open() and OpenAsync(CancellationToken) fail in the .NET Framework 4.5 if running on a Windows 7 machine with a non-IFS Winsock BSP or LSP are present on the computer.To determine whether a non-IFS BSP or LSP is installed, use the netsh WinSock Show Catalog command, and examine every Winsock Catalog Provider Entry item that is returned. If the Service Flags value has the 0x20000 bit set, the provider uses IFS handles and will work correctly. If the 0x20000 bit is clear (not set), it is a non-IFS BSP or LSP. |
Suggestion | This bug has been fixed in the .NET Framework 4.5.2, so it can be avoided by upgrading the .NET Framework. Alternatively, it can be avoided by removing any installed non-IFS Winsock LSPs. |
Scope | Minor |
Version | 4.5 |
Type | Runtime |
Affected APIs |
Entity Framework
EF no longer throws for QueryViews with specific characteristics
Details | Entity Framework no longer throws a StackOverflowException exception when an app executes a query that involves a QueryView with a 0.1 navigation property that attempts to include the related entities as part of the query. For example, by calling .Include(e => e.RelatedNavProp) . |
Suggestion | This change only affects code that uses QueryViews with 1-0.1 relationships when running queries that call .Include. It improves reliability and should be transparent to almost all apps. However, if it causes unexpected behavior, you can disable it by adding the following entry to the <appSettings> section of the app's configuration file: |
Scope | Edge |
Version | 4.5.2 |
Type | Runtime |
Opt-in break to revert from different 4.5 SQL generation to simpler 4.0 SQL generation
Details | Queries that produce JOIN statements and contain a call to a limiting operation without first using OrderBy now produce simpler SQL. After upgrading to .NET Framework 4.5, these queries produced more complicated SQL than previous versions. |
Suggestion | This feature is disabled by default. If Entity Framework generates extra JOIN statements that cause performance degradation, you can enable this feature by adding the following entry to the <appSettings> section of the application configuration (app.config) file: |
Scope | Transparent |
Version | 4.5.2 |
Type | Runtime |
Serialization
NetDataContractSerializer fails to deserialize a ConcurrentDictionary serialized with a different .NET version
Details | By design, the NetDataContractSerializer can be used only if both the serializing and deserializing ends share the same CLR types. Therefore, it is not guaranteed that an object serialized with one version of the .NET Framework can be deserialized by a different version.ConcurrentDictionary<TKey,TValue> is a type that is known to not to deserialize correctly if serialized with the .NET Framework 4.5 or earlier and deserialized with the .NET Framework 4.5.1 or later. |
Suggestion | There are a number of possible work-arounds for this issue:
|
Scope | Minor |
Version | 4.5.1 |
Type | Runtime |
Affected APIs |
Windows Communication Foundation (WCF)
MinFreeMemoryPercentageToActiveService is now respected
Details | This setting establishes the minimum memory that must be available on the server before a WCF service can be activated. It is designed to prevent OutOfMemoryException exceptions. In the .NET Framework 4.5, this setting had no effect. In the .NET Framework 4.5.1, the setting is observed. |
Suggestion | An exception occurs if the free memory available on the web server is less than the percentage defined by the configuration setting. Some WCF services that successfully started and ran in a constrained memory environment may now fail. |
Scope | Minor |
Version | 4.5.1 |
Type | Runtime |
Windows Presentation Foundation (WPF)
Calling DataGrid.CommitEdit from a CellEditEnding handler drops focus
Details | Calling CommitEdit() from one of the DataGrid's CellEditEnding event handlers causes the DataGrid to lose focus. |
Suggestion | This bug has been fixed in the .NET Framework 4.5.2, so it can be avoided by upgrading the .NET Framework. Alternatively, it can be avoided by explicitly re-selecting the DataGrid after calling CommitEdit(). |
Scope | Edge |
Version | 4.5 |
Type | Runtime |
Affected APIs |
Intermittently unable to scroll to bottom item in ItemsControls (like ListBox and DataGrid) when using custom DataTemplates
Details | In some instances, a bug in the .NET Framework 4.5 is causing ItemsControls (like ListBox, ComboBox, DataGrid, etc.) to not scroll to their bottom item when using custom DataTemplates. If the scrolling is attempted a second time (after scrolling back up), it will work then. |
Suggestion | This issue has been fixed in the .NET Framework 4.5.2 and may be addressed by upgrading to that version (or a later version) of the .NET Framework. Alternatively, users can still drag scroll bars to the final items in these collections, but may need to try twice to do so successfully. |
Scope | Minor |
Version | 4.5 |
Type | Runtime |
Scrolling a WPF TreeView or grouped ListBox in a VirtualizingStackPanel can cause a hang
Details | In the .NET Framework v4.5, scrolling a WPF TreeView in a virtualized stack panel can cause hangs if there are margins in the viewport (between the items in the TreeView, for example, or on an ItemsPresenter element). Additionally, in some cases, different sized items in the view can cause instability even if there are no margins. |
Suggestion | This bug can be avoided by upgrading to .NET Framework 4.5.1. Alternatively, margins can be removed from view collections (like TreeViews) within virtualized stack panels if all contained items are the same size. |
Scope | Major |
Version | 4.5 |
Type | Runtime |
Affected APIs |
WPF spawns a wisptis.exe process which can freeze the mouse
Details | An issue was introduced in 4.5.2 that causes wisptis.exe to be spawned that can freeze mouse input. |
Suggestion | A fix for this issue is available in a servicing release of the .NET Framework 4.5.2 (hotfix rollup 3026376), or by upgrading to the .NET Framework 4.6 |
Scope | Major |
Version | 4.5.2 |
Type | Runtime |
Users can install and run multiple versions of the .NET Framework on their computers. When you develop or deploy your app, you might need to know which .NET Framework versions are installed on the user’s computer. The registry contains a list of the .NET Framework versions installed on a computer.
If the ribbon looks similar to the following image (ribbon tabs with sharp corners), you are using either Office 2013 or 2016. Under Office Updates, the exact version number and build number are listed. If your ribbon looks different, skip to the next section.To find out more details about which version of Office 2013 or 2016 you are using, click the “File” tab.On the backstage screen, click “Account” in the list of items on the left.On the right side of the Account screen, you’ll see which edition of Office you’re using and whether or not you have a subscription product.
The .NET Framework consists of two main components, which are versioned separately:
A set of assemblies, which are collections of types and resources that provide the functionality for your apps. The .NET Framework and assemblies share the same version number. For example, .NET Framework versions include 4.5, 4.6.1, and 4.7.2.
The common language runtime (CLR), which manages and executes your app's code. A single CLR version typically supports multiple .NET Framework versions. For example, CLR version 4.0.30319.xxxxx where xxxxx is less than 42000, supports .NET Framework versions 4 through 4.5.2. CLR version greater than or equal to 4.0.30319.42000 supports .NET Framework versions starting with .NET Framework 4.6.
Community-maintained tools are available to help detect which .NET Framework versions are installed:
A .NET 2.0 command-line tool.
A PowerShell 2.0 module.
For information about detecting the installed updates for each version of the .NET Framework, see How to: Determine which .NET Framework updates are installed.
Detect .NET Framework 4.5 and later versions
The version of .NET Framework (4.5 and later) installed on a machine is listed in the registry at HKEY_LOCAL_MACHINESOFTWAREMicrosoftNET Framework SetupNDPv4Full. If the Full subkey is missing, then .NET Framework 4.5 or above isn't installed.
Note
The NET Framework Setup subkey in the registry path does not begin with a period.
The Release REG_DWORD value in the registry represents the version of .NET Framework installed.
.NET Framework version | Value of Release |
---|---|
.NET Framework 4.5 | All Windows operating systems: 378389 |
.NET Framework 4.5.1 | On Windows 8.1 and Windows Server 2012 R2: 378675 On all other Windows operating systems: 378758 |
.NET Framework 4.5.2 | All Windows operating systems: 379893 |
.NET Framework 4.6 | On Windows 10: 393295 On all other Windows operating systems: 393297 |
.NET Framework 4.6.1 | On Windows 10 November Update systems: 394254 On all other Windows operating systems (including Windows 10): 394271 |
.NET Framework 4.6.2 | On Windows 10 Anniversary Update and Windows Server 2016: 394802 On all other Windows operating systems (including other Windows 10 operating systems): 394806 |
.NET Framework 4.7 | On Windows 10 Creators Update: 460798 On all other Windows operating systems (including other Windows 10 operating systems): 460805 |
.NET Framework 4.7.1 | On Windows 10 Fall Creators Update and Windows Server, version 1709: 461308 On all other Windows operating systems (including other Windows 10 operating systems): 461310 |
.NET Framework 4.7.2 | On Windows 10 April 2018 Update and Windows Server, version 1803: 461808 On all Windows operating systems other than Windows 10 April 2018 Update and Windows Server, version 1803: 461814 |
.NET Framework 4.8 | On Windows 10 May 2019 Update and Windows 10 November 2019 Update: 528040 On Windows 10 and Windows Server, version 1909: 528209 On all other Windows operating systems (including other Windows 10 operating systems): 528049 |
Minimum version
To determine whether a minimum version of the .NET Framework is present, use the smallest Release REG_DWORD value for that version from the previous table.
For example, if your application runs under .NET Framework 4.8 or a later version, test for a Release REG_DWORD value that is greater than or equal to 528040.
.NET Framework version | Minimum value |
---|---|
.NET Framework 4.5 | 378389 |
.NET Framework 4.5.1 | 378675 |
.NET Framework 4.5.2 | 379893 |
.NET Framework 4.6 | 393295 |
.NET Framework 4.6.1 | 394254 |
.NET Framework 4.6.2 | 394802 |
.NET Framework 4.7 | 460798 |
.NET Framework 4.7.1 | 461308 |
.NET Framework 4.7.2 | 461808 |
.NET Framework 4.8 | 528040 |
Use Registry Editor
From the Start menu, choose Run, enter regedit, and then select OK.
You must have administrative credentials to run regedit.
In the Registry Editor, open the following subkey: HKEY_LOCAL_MACHINESOFTWAREMicrosoftNET Framework SetupNDPv4Full. If the Full subkey isn't present, then you don't have the .NET Framework 4.5 or later installed.
Check for a REG_DWORD entry named Release. If it exists, then you have .NET Framework 4.5 or later installed. Its value corresponds to a particular version of the .NET Framework. In the following figure, for example, the value of the Release entry is 528040, which is the release key for .NET Framework 4.8.
Use PowerShell to check for a minimum version
Use PowerShell commands to check the value of the Release entry of the HKEY_LOCAL_MACHINESOFTWAREMicrosoftNET Framework SetupNDPv4Full subkey.
The following examples check the value of the Release entry to determine whether the .NET Framework 4.6.2 or later is installed. This code returns True
if it's installed and False
otherwise.
Query the registry using code
Use the RegistryKey.OpenBaseKey and RegistryKey.OpenSubKey methods to access the HKEY_LOCAL_MACHINESOFTWAREMicrosoftNET Framework SetupNDPv4Full subkey in the Windows registry.
Important
If the app you're running is 32-bit and running in 64-bit Windows, the registry paths will be different than previously listed. The 64-bit registry is available in the HKEY_LOCAL_MACHINESOFTWAREWow6432Node subkey. For example, the registry subkey for .NET Framework 4.5 is HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftNET Framework SetupNDPv4Full.
Check the Release REG_DWORD value to determine the installed version. To be forward-compatible, check for a value greater than or equal to the value listed in the .NET Framework version table.
The following example checks the value of the Release entry in the registry to find the .NET Framework 4.5 and later versions that are installed:
This example follows the recommended practice for version checking:
Microsoft Visual C++
- It checks whether the value of the Release entry is greater than or equal to the value of the known release keys.
- It checks in order from most recent version to earliest version.
Detect .NET Framework 1.0 through 4.0
Each version of .NET Framework from 1.1 to 4.0 is listed as a subkey at HKEY_LOCAL_MACHINESOFTWAREMicrosoftNET Framework SetupNDP. The following table lists the path to each .NET Framework version. For most versions, there's a Install REG_DWORD value of 1
to indicate this version is installed. In these subkeys, there's also a Version REG_SZ value that contains a version string.
Note
The NET Framework Setup subkey in the registry path does not begin with a period.
Framework Version | Registry Subkey | Value |
---|---|---|
1.0 | HKLMSoftwareMicrosoft.NETFrameworkPolicyv1.03705 | Install REG_SZ equals 1 |
1.1 | HKLMSoftwareMicrosoftNET Framework SetupNDPv1.1.4322 | Install REG_DWORD equals 1 |
2.0 | HKLMSoftwareMicrosoftNET Framework SetupNDPv2.0.50727 | Install REG_DWORD equals 1 |
3.0 | HKLMSoftwareMicrosoftNET Framework SetupNDPv3.0Setup | InstallSuccess REG_DWORD equals 1 |
3.5 | HKLMSoftwareMicrosoftNET Framework SetupNDPv3.5 | Install REG_DWORD equals 1 |
4.0 Client Profile | HKLMSoftwareMicrosoftNET Framework SetupNDPv4Client | Install REG_DWORD equals 1 |
4.0 Full Profile | HKLMSoftwareMicrosoftNET Framework SetupNDPv4Full | Install REG_DWORD equals 1 |
Important
If the app you're running is 32-bit and running in 64-bit Windows, the registry paths will be different than previously listed. The 64-bit registry is available in the HKEY_LOCAL_MACHINESOFTWAREWow6432Node subkey. For example, the registry subkey for .NET Framework 3.5 is HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftNET Framework SetupNDPv3.5.
Notice that the registry path to the .NET Framework 1.0 subkey is different from the others.
Use Registry Editor (older framework versions)
From the Start menu, choose Run, enter regedit, and then select OK.
You must have administrative credentials to run regedit.
Open the subkey that matches the version you want to check. Use the table in the Detect .NET Framework 1.0 through 4.0 section.
The following figure shows the subkey and its Version value for .NET Framework 3.5.
Query the registry using code (older framework versions)
Use the Microsoft.Win32.RegistryKey class to access the HKEY_LOCAL_MACHINESOFTWAREMicrosoftNET Framework SetupNDP subkey in the Windows registry.
Important
If the app you're running is 32-bit and running in 64-bit Windows, the registry paths will be different than previously listed. The 64-bit registry is available in the HKEY_LOCAL_MACHINESOFTWAREWow6432Node subkey. For example, the registry subkey for .NET Framework 3.5 is HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftNET Framework SetupNDPv3.5.
The following example finds the .NET Framework 1 through 4 versions that are installed:
Find CLR versions
Microsoft Dot Net 4.5.2 Framework
The .NET Framework CLR installed with .NET Framework is versioned separately. There are two ways to detect the version of the .NET Framework CLR:
The Clrver.exe tool
Use the CLR Version tool (Clrver.exe) to determine which versions of the CLR are installed on a computer. Open the Developer Command Prompt for Visual Studio and enter
clrver
.Sample output:
The
Environment
classImportant
For .NET Framework 4.5 and later versions, don't use the Environment.Version property to detect the version of the CLR. Instead, query the registry as described in Detect .NET Framework 4.5 and later versions.
Query the Environment.Version property to retrieve a Version object.
The returned
System.Version
object identifies the version of the runtime that's currently executing the code. It doesn't return assembly versions or other versions of the runtime that may have been installed on the computer.For .NET Framework versions 4, 4.5, 4.5.1, and 4.5.2, the string representation of the returned Version object has the form 4.0.30319.xxxxx, where xxxxx is less than 42000. For .NET Framework 4.6 and later versions, it has the form 4.0.30319.42000.
After you have the Version object, query it as follows:
For the major release identifier (for example, 4 for version 4.0), use the Version.Major property.
For the minor release identifier (for example, 0 for version 4.0), use the Version.Minor property.
For the entire version string (for example, 4.0.30319.18010), use the Version.ToString method. This method returns a single value that reflects the version of the runtime that's executing the code. It doesn't return assembly versions or other runtime versions that may be installed on the computer.
The following example uses the Environment.Version property to retrieve CLR version information: