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
32
votes
3 answers

Mixing .NET 3.5 with 4/4.5 assemblies in the same process

I'd like to migrate a .NET 3.5 WinForms based application to the latest .NET version (4.5). The application uses "external" components (can be thought of as plugins) that are also currently .NET 3.5 based. I'd like to know what runtime/core…
lysergic-acid
  • 19,570
  • 21
  • 109
  • 218
31
votes
7 answers

Will .NET 4.5 introduce a new version of the CLR?

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?
Michiel van Oosterhout
  • 22,839
  • 15
  • 90
  • 132
31
votes
4 answers

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

This causes an AccessViolationException to be thrown: using System; namespace TestApplication { internal static class Program { private static unsafe void Main() { ulong* addr = (ulong*)Int64.MaxValue; …
Michael J. Gray
  • 9,784
  • 6
  • 38
  • 67
31
votes
5 answers

How to see JIT-Compiled code in .NET VM (CLR)

How can I have a trace of native code generated by the JIT-Compiler ? Thanks
Thomas
  • 313
  • 3
  • 4
31
votes
5 answers

How does C# compilation get around needing header files?

I've spent my professional life as a C# developer. As a student I occasionally used C but did not deeply study it's compilation model. Recently I jumped on the bandwagon and have begun studying Objective-C. My first steps have only made me aware of…
G-Wiz
  • 7,370
  • 1
  • 36
  • 47
31
votes
6 answers

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

Which other restrictions are there on names (beside the obvious uniqueness within a scope)? Where are those defined?
David Schmitt
  • 58,259
  • 26
  • 121
  • 165
29
votes
7 answers

Assert.AreEqual() with System.Double getting really confusing

Description This is not a real world example! Please don't suggest using decimal or something else. I am only asking this because I really want to know why this happens. I recently saw the awesome Tekpub Webcast Mastering C# 4.0 with Jon Skeet…
dknaack
  • 60,192
  • 27
  • 155
  • 202
29
votes
5 answers

How does catching an OutOfMemoryException work?

I am a little bit confused about the fact that we can just catch an OutOfMemoryException using a try/catch block. Given the following code: Console.WriteLine("Starting"); for (int i = 0; i < 10; i++) { try { OutOfMemory(); } …
GameScripting
  • 16,092
  • 13
  • 59
  • 98
28
votes
2 answers

In .NET 4.0, What is the default implementation of Equals for value types?

The two documentation pages seem to contradict on this topic: ValueType.Equals Method says "The default implementation of the Equals method uses reflection to compare the corresponding fields of obj and this instance." Object.Equals Method…
Gebb
  • 6,371
  • 3
  • 44
  • 56
28
votes
3 answers

What's the method representation in memory?

While thinking a little bit about programming in Java/C# I wondered about how methods which belong to objects are represented in memory and how this fact does concern multi threading. Is a method instantiated for each object in memory seperately…
Emiswelt
  • 3,909
  • 1
  • 38
  • 56
28
votes
7 answers

How does Parrot compare to other virtual machines?

Parrot is the virtual machine originally designed for Perl 6. What technical capabilities does the Parrot VM offer that competing virtual machines such as the Java Virtual Machine (JVM)/Hotspot VM and Common Language Runtime (CLR) lack?
knorv
  • 49,059
  • 74
  • 210
  • 294
28
votes
2 answers

WeakReference implementation in .NET

I understand and appreciate the usefulness of the System.WeakReference class in the .NET framework, but am curious as to the implementation details. How is WeakReference implemented in .NET? MSDN discusses the usage of WeakReference in detail, but…
Reed Copsey
  • 554,122
  • 78
  • 1,158
  • 1,373
27
votes
3 answers

Green threads in .NET

Green threads were introduced in Erlang and probably all languages based on it know them, also in go (gorutines). Then afaik they were removed from rust. My questions: How would one implement green threads in .NET? Are there some caveats that…
stej
  • 28,745
  • 11
  • 71
  • 104
27
votes
1 answer

Why would the .NET JIT compiler decide to not inline or optimize away calls to empty static methods that have no side effects?

I think I'm observing the .NET JIT compiler not inlining or optimizing away calls to empty static methods that have no side effects, which is a bit surprising given some bespoken online resources. My environment is Visual Studio 2013 on x64, Windows…
Johann Gerell
  • 24,991
  • 10
  • 72
  • 122
27
votes
3 answers

When passing a managed byte[] array through PInvoke to be filled in by Win32, does it need to be pinned?

Suppose you're calling a Win32 function that will fill in your byte array. You create an array of size 32, empty. Then pass it in to the Win32 function to be filled int, and use it later in your managed code. Does there exist the chance that the…
Leeks and Leaks
  • 1,258
  • 1
  • 16
  • 26