سؤال

In the past not every new version of .NET came with a new version of the CLR. I know .NET 1.0, 1.1, 2.0 and 4.0 did, but .NET 3.0 and 3.5 did not.

Will .NET 4.5 introduce a new CLR? And how does one tell if there's a new CLR?

هل كانت مفيدة؟

المحلول

Yes, .NET 4.5 has a brand spanking new version of the CLR, you can read about the improvements at;

http://blogs.microsoft.co.il/blogs/sasha/archive/2011/09/17/improvements-in-the-clr-core-in-net-framework-4-5.aspx

To clarify; this is a new version of the CLR that actually replaces the 4.0 one, so whether to call it an update or a new CLR is disputable.

To tell which CLR version you're running under, use

System.Runtime.InteropServices.RuntimeEnvironment.GetSystemVersion()

نصائح أخرى

No, it is still version 4.0.30319. The new revision of clr.dll and friends will replace the existing ones on your machine. Same scheme as used in .NET 3.0, 3.5 and 3.5SP1. Checking to see if 4.5 is installed requires the same approach as those versions, you check the registry.

Yes. The version of the CLR changes from 4.0.30319.269 to 4.0.30319.17379. So, the CLR is new, but it is backwards-compatible with the .NET 4.0 CLR. You shouldn't need to re-compile any code written for and compiled by .NET v4.0.

From the .NET Framework Versions and Dependencies page on MSDN:

The .NET Framework 4.5 RC is an in-place update that replaces the .NET Framework 4 on your computer. After you install this update, your .NET Framework 4 apps should continue to run without requiring recompilation. However, some changes in the .NET Framework may require changes to your app code.

Additionally, from the .NET Framework blog:

.NET Framework 4.5 is an in-place update that replaces .NET Framework 4 (rather than a side-by-side installation). Our goal is for .NET 4.5 to be fully backward compatible with applications built for .NET 4

There are some changes that are not backwards compatible. See the Application Compatibility in the .NET Framework 4.5 RC page on MSDN.

Official guidance from Microsoft, and good coding practice, is not to detect specific versions of the CLR. Rather, you should detect if certain features are present. Instead of

public static bool IsDotNet45()
{
    return Environment.Version.Major == 4 &&
           Environment.Version.Revision > 17000;
}

do something like:

public static bool SupportsReflectionContext()
{
    // Class "ReflectionContext" exists from .NET 4.5 onwards.
    return Type.GetType("System.Reflection.ReflectionContext", false) != null;
}

Although I doubt that this was available in it's current format at the time of the question, here is the CLR Guide on MSDN where it shows all of the Framework versions and the CLR version that they include. I found it very helpful, so I thought I would share.

Next to .NET 4.5 it states that it includes CLR 4.

.NET 4 and .NET 4.5 (including 4.5.1 and 4.5.2) are on the CLR version 4.0

More detail: https://msdn.microsoft.com/en-us/library/8bs2ecf4(v=vs.110).aspx

.NET Framework 4.5 is like a service pack to .NET Framework 4 with some additional features.

Scott Hanselman has a post on his blog addressing this question. You can find out about it here:

http://www.hanselman.com/blog/NETVersioningAndMultiTargetingNET45IsAnInplaceUpgradeToNET40.aspx

The short of it is that there are updates to the CLR that improve performance and added new libraries. The CLR used by .NET 4.5 is compatible with .NET 4. It's considered to be a minor update. These minor updates are what Microsoft calls an in-place update.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top