Questions tagged [clr]

The Common Language Runtime (CLR) is a core component of Microsoft's .NET initiative. It is Microsoft's implementation of the Common Language Infrastructure (CLI) standard, which defines an execution environment for program code. In the CLR, code is expressed in a form of bytecode called the Common Intermediate Language (CIL, previously known as MSIL—Microsoft Intermediate Language).

Developers using the CLR write code in a language such as C# or VB.NET. At compile time, a .NET compiler converts such code into CIL code. At runtime, the CLR's just-in-time compiler converts the CIL code into code native to the operating system. Alternatively, the CIL code can be compiled to native code in a separate step prior to runtime by using the Native Image Generator (NGEN). This speeds up all later runs of the software as the CIL-to-native compilation is no longer necessary.

Although some other implementations of the Common Language Infrastructure run on non-Windows operating systems, Microsoft's .NET Framework implementation runs only on Microsoft Windows operating systems.

Books

Articles

3930 questions
71
votes
5 answers

What are the roots?

What are the roots in garbage collection? I have read the definition of root as "any reference that you program can access to" and definition of live is that an object that is being used, which can be a local variable, static variable. I m little…
DarthVader
  • 52,984
  • 76
  • 209
  • 300
65
votes
7 answers

Is the CLR a virtual machine?

I read a book which referred to the .net CLR as a virtual machine? Can anyone justify this? What is the reason we need the concept of virtual machines on some development platforms? Isn't it possible to develop a native framework [one without…
this. __curious_geek
  • 42,787
  • 22
  • 113
  • 137
65
votes
4 answers

In a switch vs dictionary for a value of Func, which is faster and why?

Suppose there is the following code: private static int DoSwitch(string arg) { switch (arg) { case "a": return 0; case "b": return 1; case "c": return 2; case "d": return 3; } return -1; } private…
cubetwo1729
  • 1,438
  • 1
  • 11
  • 18
64
votes
3 answers

Performance: type derived from generic

I've encountered with one performance problem that I can't quite understand. I know how to fix it but I don't understand Why that happens. It's just for fun! Let's talk code. I simplified the code as much as I could to reproduce the issue. Suppose…
Alexandr Nikitin
  • 7,258
  • 2
  • 34
  • 42
62
votes
7 answers

How do I detect at runtime that .NET version 4.5 is currently running your code?

I installed .NET 4.5 Developer preview from http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=27541, which 'replaces' .NET 4.0 version. However, the old way to detect the .NET framework version seems to return 4.0 (more precisely…
Evereq
  • 1,662
  • 1
  • 18
  • 23
62
votes
7 answers

CLR and CLI - What is the difference?

I want to know what exactly is the difference between CLR & CLI? From whatever I have read so far, it seems to indicate that CLI is a subset of CLR. But isn't everything in the CLR mandatory? What exactly may be left out of CLR to create a CLI?
Naveen
  • 74,600
  • 47
  • 176
  • 233
61
votes
8 answers

LINQ on the .NET 2.0 Runtime

Can a LINQ enabled app run on a machine that only has the .NET 2.0 runtime installed? In theory, LINQ is nothing more than syntactic sugar, and the resulting IL code should look the same as it would have in .NET 2.0. How can I write LINQ without…
urini
  • 32,483
  • 14
  • 40
  • 37
59
votes
4 answers

How do the .NET Framework, CLR and Visual Studio version numbers relate to each other?

With the recent announcement of .NET 4.0 and Visual Studio 2010, it is becoming ever more difficult to keep track of what .NET Framework versions build on what version of the CLR and belong with which version(s) of Visual Studio. Is there a…
Scott Dorman
  • 42,236
  • 12
  • 79
  • 110
58
votes
4 answers

Stack capacity in C#

Could someone tell me what the stack capacity is in C#. I am trying to form a 3D mesh closed object using an array of 30,000 items.
George ARKIN
57
votes
4 answers

Force x86 CLR on an 'Any CPU' .NET assembly

In .NET, the 'Platform Target: Any CPU' compiler option allows a .NET assembly to run as 64 bit on a x64 machine, and 32 bit on an x86 machine. It is also possible to force an assembly to run as x86 on an x64 machine using the 'Platform Target: x86'…
jeffora
  • 4,009
  • 2
  • 25
  • 38
54
votes
7 answers

CLR vs JIT

What is the difference between the JIT compiler and CLR? If you compile your code to il and CLR runs that code then what is the JIT doing? How has JIT compilation changed with the addition of generics to the CLR?
Ted Smith
  • 9,415
  • 16
  • 50
  • 52
54
votes
3 answers

Clojure on the CLR

I'm interested in investigating Clojure on the CLR. I see that there is a port--but I'm always a bit leery of these second-class citizens (i.e. they don't have the stability or functionality of the original). I'd less inclined to spend much time at…
Kevin Won
  • 7,156
  • 5
  • 36
  • 54
53
votes
6 answers

.NET vs ASP.NET vs CLR vs ASP

Although I know the terms I used to forget the differences sometimes...So just to maintain a place for reference...Thanks all for your answers.
Vishal
  • 12,133
  • 17
  • 82
  • 128
53
votes
4 answers

Interface with generic parameter vs Interface with generic methods

Let's say I have such interface and concrete implementation public interface IMyInterface { T My(); } public class MyConcrete : IMyInterface { public string My() { return string.Empty; } } So I create MyConcrete…
Jevgenij Nekrasov
  • 2,690
  • 3
  • 30
  • 51
51
votes
5 answers

Strange casting behaviour. Cannot cast object (int) to long

I have the following code: int intNumber1 = 100; object intNumber2 = 100; bool areNumberOfTheSameType = intNumber1.GetType() == intNumber2.GetType(); // TRUE bool areEqual = intNumber1.Equals(intNumber2); // TRUE long longNumber1 = (long)…
Bashir Magomedov
  • 2,841
  • 4
  • 28
  • 44