Will .NET 4.5 introduce a new version of the 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 … Read more

Why is memory access in the lowest address space (non-null though) reported as NullReferenceException by .NET?

This is caused by a Windows design decision made many years ago. The bottom 64 kilobytes of the address space is reserved. An access to any address in that range is reported with a null reference exception instead of the underlying access violation. This was a wise choice, a null pointer can produce reads or … Read more

What is the maximum length of a C#/CLI identifier?

In addition to the other answers, the maximum identifier length that is accepted by the Microsoft Visual C# compiler is 511 characters. This can be tested with the following code: class Program { private static void Main(string[] args) { int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = 5; } } The length of the variable name there is 511 characters. … Read more

the common language runtime was unable to set the breakpoint

Two possibilities, already kind of referenced by the other answers: Make sure you are using the Debug build of the assembly instead of the Release build, because the Release build will remove or optimize your code. Make sure you are updating the version each time you deploy the assemblies in Visual Studio (on project properties … Read more

Memory allocation when using foreach loops in C#

Foreach can cause allocations, but at least in newer versions .NET and Mono, it doesn’t if you’re dealing with the concrete System.Collections.Generic types or arrays. Older versions of these compilers (such as the version of Mono used by Unity3D until 5.5) always generate allocations. The C# compiler uses duck typing to look for a GetEnumerator() … Read more

Why only literal strings saved in the intern pool by default?

The short answer: interning literal strings is cheap at runtime and saves memory. Interning non-literal strings is expensive at runtime and therefore saves a tiny amount of memory in exchange for making the common cases much slower. The cost of the interning-strings-at-runtime “optimization” does not pay for the benefit, and is therefore not actually an … Read more

tech