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
49
votes
7 answers

sizeof(int) on x64?

When I do sizeof(int) in my C#.NET project I get a return value of 4. I set the project type to x64, so why does it say 4 instead of 8? Is this because I'm running managed code?
iheartcsharp
  • 1,279
  • 1
  • 14
  • 22
49
votes
6 answers

Where is the .NET JIT-compiled code cached?

A .NET program is first compiled into MSIL code. When it is executed, the JIT compiler will compile it into native machine code. I am wondering: Where is these JIT-compiled machine code stored? Is it only stored in address space of the process?…
smwikipedia
  • 61,609
  • 92
  • 309
  • 482
49
votes
5 answers

Get Current .NET CLR version at runtime?

How can I get the current CLR Runtime version in a running .NET program ?
driis
  • 161,458
  • 45
  • 265
  • 341
48
votes
6 answers

How to detect which .NET runtime is being used (MS vs. Mono)?

I would like to know during execution of a program whether it is being executed using the Mono runtime or the Microsoft runtime. I'm currently using the following code to determine whether I'm on a MS CLR: static bool IsMicrosoftCLR() { return…
Dirk Vollmar
  • 172,527
  • 53
  • 255
  • 316
48
votes
7 answers

"Object has been disconnected or does not exist at the server" exception

I need to use cross-appdomain calls in my app, and sometimes I have this RemotingException: Object '/2fa53226_da41_42ba_b185_ec7d9c454712/ygiw+xfegmkhdinj7g2kpkhc_7.rem' has been disconnected or does not exist at the server. The target object is…
user626528
  • 13,999
  • 30
  • 78
  • 146
48
votes
2 answers

Is MarshalByRefObject special?

.NET has a thing called remoting where you can pass objects around between separate appdomains or even physical machines. I don't fully understand how the magic is done, hence this question. In remoting there are two base ways of passing objects…
Vilx-
  • 104,512
  • 87
  • 279
  • 422
48
votes
11 answers

Is casting the same thing as converting?

In Jesse Liberty's Learning C# book, he says "Objects of one type can be converted into objects of another type. This is called casting." If you investigate the IL generated from the code below, you can clearly see that the casted assignment isn't…
rp.
  • 17,483
  • 12
  • 63
  • 79
47
votes
8 answers

Have you ever used ngen.exe?

Has anybody here ever used ngen? Where? why? Was there any performance improvement? when and where does it make sense to use it?
Hannoun Yassir
  • 20,583
  • 23
  • 77
  • 112
46
votes
5 answers

Why cannot C# generics derive from one of the generic type parameters like they can in C++ templates?

Why cannot C# generics derive from one of the generic type parameters like they can in C++ templates? I mean I know it impossible because CLR does not support this, but why? I am aware of the profound differences between C++ templates and C#…
mark
  • 59,016
  • 79
  • 296
  • 580
45
votes
6 answers

Are C# uninitialized variables dangerous?

I'm familiar with the C# specification, section 5.3 which says that a variable has to be assigned before use. In C and unmanaged C++ this makes sense as the stack isn't cleared and the memory location used for a pointer could be anywhere (leading to…
jmoreno
  • 12,752
  • 4
  • 60
  • 91
45
votes
3 answers

In C++/CLI, what does the hat character ^ do?

I was reading Ivor Horton's Beginning Visual C++ 2008 and many of its CLR examples have this definition for main: int main(array ^args) I went back, page by page, to the beginning of the book to find the first such instance with…
Tuminoid
  • 9,445
  • 7
  • 36
  • 51
45
votes
2 answers

How is GetHashCode() implemented for Int32?

I've been looking all over the place, but I can't find anything. Can anyone shed some light on this?
Esteban Araya
  • 29,284
  • 24
  • 107
  • 141
45
votes
7 answers

Does the .NET CLR Really Optimize for the Current Processor

When I read about the performance of JITted languages like C# or Java, authors usually say that they should/could theoretically outperform many native-compiled applications. The theory being that native applications are usually just compiled for a…
dewald
  • 5,133
  • 7
  • 38
  • 42
44
votes
3 answers

Asynchronous iterator Task>

I’m trying to implement an asynchronous function that returns an iterator. The idea is the following: private async Task> TestAsync(string testString) { foreach (char c in testString.ToCharArray()) { …
user2341923
  • 4,537
  • 6
  • 30
  • 44
44
votes
2 answers

Equivalent of Class Loaders in .NET

Does anyone know if it possible to define the equivalent of a "java custom class loader" in .NET? To give a little background: I am in the process of developing a new programming language that targets the CLR, called "Liberty". One of the features…