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
43
votes
4 answers

Haskell for the .NET platform?

I'm a .NET developer by day, but have been playing with Haskell in my spare time for awhile now. I'm curious: any Haskell .net implementations in the same vein as IronPython?
Will
  • 433
  • 1
  • 4
  • 6
42
votes
2 answers

explicitly cast generic type parameters to any interface

In Generics FAQ: Best Practices says : The compiler will let you explicitly cast generic type parameters to any interface, but not to a class: interface ISomeInterface {...} class SomeClass {...} class MyClass { void SomeMethod(T t) { …
Incognito
  • 16,567
  • 9
  • 52
  • 74
42
votes
8 answers

How is it that an enum derives from System.Enum and is an integer at the same time?

Edit: Comments at bottom. Also, this. Here's what's kind of confusing me. My understanding is that if I have an enum like this... enum Animal { Dog, Cat } ...what I've essentially done is defined a value type called Animal with two defined…
Dan Tao
  • 125,917
  • 54
  • 300
  • 447
41
votes
5 answers

When is a method eligible to be inlined by the CLR?

I've observed a lot of "stack-introspective" code in applications, which often implicitly rely on their containing methods not being inlined for their correctness. Such methods commonly involve calls…
Ani
  • 111,048
  • 26
  • 262
  • 307
41
votes
9 answers

Are there any .NET CLR/DLR implementations of ECMAScript?

Does anyone know of real (i.. no vaporware) implementations of ECMAScript targeting the .NET CLR/DLR? Ideally something like what Rhino is for Java. A solid port of Rhino running on .NET Framework / Mono Framework would be perfect. I've only seen a…
mckamey
  • 17,359
  • 16
  • 83
  • 116
39
votes
1 answer

What's the difference between .NET CoreCLR, CoreRT, Roslyn and LLILC

Recently I started reading about .NET reorganization details (mostly through .NET Core github pages). It seams that they created sibling projects to support more platforms. While reading I have the impression that CoreCLR and CoreRT is a new…
Robert Zaremba
  • 8,081
  • 7
  • 47
  • 78
38
votes
6 answers

Why are sealed types faster?

Why are sealed types faster? I am wondering about the deeper details about why this is true.
Joan Venge
  • 315,713
  • 212
  • 479
  • 689
38
votes
7 answers

Why doesn't the CLR always call value type constructors

I have a question concerning type constructors within a Value type. This question was inspired by something that Jeffrey Richter wrote in CLR via C# 3rd ed, he says (on page 195 - chapter 8) that you should never actually define a type constructor…
jameschinnock
  • 767
  • 6
  • 14
38
votes
2 answers

SecurityException: ECall methods must be packaged into a system module

I have a (C#) function similar to the following. private static bool SpecialCase = false; public void Foo() { if (SpecialCase) { InternalMethod(); return; } …
Sam Harwell
  • 97,721
  • 20
  • 209
  • 280
37
votes
4 answers

Instantiation of recursive generic types slows down exponentially the deeper they are nested. Why?

Note: I may have chosen the wrong word in the title; perhaps I'm really talking about polynomial growth here. See the benchmark result at the end of this question. Let's start with these three recursive generic interfaces† that represent immutable…
stakx - no longer contributing
  • 83,039
  • 20
  • 168
  • 268
37
votes
4 answers

What's the point of MethodImplOptions.InternalCall?

Many methods in the BCL are marked with the [MethodImpl(MethodImplOptions.InternalCall)] attribute. This indicates that the "method is implemented within the common language runtime itself". What was the point of designing the framework in this…
Ani
  • 111,048
  • 26
  • 262
  • 307
36
votes
8 answers

How to debug System.TypeLoadException errors in .NET?

I'm getting the following error on one of my referenced assemblies: Could not load type 'System.Func`2' from assembly 'MyAssembly, ... My first instinct was to see what MSDN had to say about it: TypeLoadException is thrown when the common language…
kertosis
  • 1,433
  • 2
  • 12
  • 10
36
votes
4 answers

What does ----s mean in the context of StringBuilder.ToString()?

The Reference Source page for stringbuilder.cs has this comment in the ToString method: if (chunk.m_ChunkLength > 0) { // Copy these into local variables so that they // are stable even in the presence of ----s (hackers might do this) …
Micteu
  • 451
  • 5
  • 17
36
votes
3 answers

Are static indexers not supported in C#?

I've been trying this a few different ways, but I'm reaching the conclusion that it can't be done. It's a language feature I've enjoyed from other languages in the past. Is it just something I should just write off?
Kilhoffer
  • 32,375
  • 22
  • 97
  • 124
35
votes
3 answers

CLR implementation of virtual method calls to interface members

Out of curiosity: how does the CLR dispatch virtual method calls to interface members to the correct implementation? I know about the VTable that the CLR maintains for each type with method slots for each method, and the fact that for each interface…
Daniel A.A. Pelsmaeker
  • 47,471
  • 20
  • 111
  • 157