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

.Net 4.0 Windows Application crashes in clr.dll under Windows Server 2008

I have a Windows application scheduled to run on a daily basis and fails intermittently as per the following log in EventViewer. Faulting application name: MyApplication.exe, version: 1.0.0.0, time stamp: 0x4d54829a Faulting module name: clr.dll,…
Rez.Net
  • 1,354
  • 2
  • 19
  • 28
35
votes
8 answers

Why are immutable objects thread-safe?

class Unit { private readonly string name; private readonly double scale; public Unit(string name, double scale) { this.name = name; this.scale = scale, } public string Name { get { return name; } } public…
randomguy
  • 12,042
  • 16
  • 71
  • 101
35
votes
2 answers

Performance of a C# application built on AnyCPU vs x64 platform on a 64 bit machine

I have to deploy a C# application on a 64 bit machine though there is a slight probability that it could also be deployed on a 32 bit machine. Should I build two separate executables targeting x86 and x64 platform or should I go for a single…
Saurabh R S
  • 3,037
  • 1
  • 34
  • 44
35
votes
5 answers

C# casting to nullable type?

Beyond the regular boring difference between Cast and As if i know that apple is a Fruit so I can use (Fruit)apple - and it throws an exception if it aint as value can be checked against null to see if succeeded [won't throw Exception...] However…
Royi Namir
  • 144,742
  • 138
  • 468
  • 792
34
votes
2 answers

What happens when a .net application is started?

I have been developing apps using .net for quite sometime now. But, I am still not sure how does the CLR know that a .net app has started. Is there like one instance of CLR per app? I don't think this can be the case as there is just one GC which…
Sandbox
  • 7,910
  • 11
  • 53
  • 67
34
votes
11 answers

Why does null exist in .NET?

Why can values be null in .NET? Is this superior to having a guarantee where everything would have a value and nothing call be null? Anyone knows what each of these methodologies are called? Either way, I am not very knowledgeable on this, but…
Joan Venge
  • 315,713
  • 212
  • 479
  • 689
33
votes
5 answers

JIT vs NGen - what is the difference?

So when CLR runtime load a .NET assembly, it compiles it into machine native code. This process is called JITing. NGen is also the process of compiling .NET assembly into native code. I don't understand what is the difference between two?
palm snow
  • 2,392
  • 4
  • 29
  • 49
33
votes
4 answers

How to call .NET methods from Excel VBA?

I found a way to call .NET 2 code directly from VBA code: Dim clr As mscoree.CorRuntimeHost Set clr = New mscoree.CorRuntimeHost clr.Start Dim domain As mscorlib.AppDomain clr.GetDefaultDomain domain Dim myInstanceOfDotNetClass As Object Set…
user1983691
  • 443
  • 1
  • 4
  • 8
33
votes
3 answers

What is CLR hosting?

What is CLR hosting? What is the use case for that?
Yaron Naveh
  • 23,560
  • 32
  • 103
  • 158
33
votes
11 answers

Unable to load SqlServerSpatial.dll

I am trying to use the SqlServer Spatial CLR types in a C# .Net project. I want to use SqlGeometry to query spatial records out of my db. I have this working on my local machine in a unit test running in Visual Studio 2010 hitting a remote SqlServer…
VBAHole
  • 1,508
  • 2
  • 24
  • 38
33
votes
1 answer

Should ConditionalWeakTable be used for non-compiler purposes?

I've recently come across the ConditionalWeakTable class in my search for an IDictionary which uses weak references, as suggested in answers here and here. There is a definitive MSDN article which introduced the class and which…
rikoe
  • 1,639
  • 1
  • 21
  • 29
32
votes
7 answers

the common language runtime was unable to set the breakpoint

This is actually another part of this question. Error settings breakpoints but only on some lines while debugging I'm remote debugging a CRM 2011 plugin in vs 2010. I'n one of my source files I can set breakpoint all throughout the code except in a…
user1231231412
  • 1,659
  • 2
  • 26
  • 42
32
votes
3 answers

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

Why by default only literal strings are saved in the intern pool? Example from MSDN: String s1 = "MyTest"; String s2 = new StringBuilder().Append("My").Append("Test").ToString(); String s3 = String.Intern(s2); Console.WriteLine("s1 == '{0}'",…
gdoron
  • 147,333
  • 58
  • 291
  • 367
32
votes
8 answers

Is there a high resolution (microsecond, nanosecond) DateTime object available for the CLR?

I have an instrument that stores timestamps the microsecond level, and I need to store those timestamps as part of collecting information from the instrument. Note that I do not need to generate timestamps; these time stamps are pre-generated by the…
Robert P
  • 15,707
  • 10
  • 68
  • 112
32
votes
4 answers

Memory allocation when using foreach loops in C#

I know the basics on how foreach loops work in C# (How do foreach loops work in C#) I am wondering whether using foreach allocates memory that may cause garbage collections? (for all built in System types). For example, using Reflector on the…
lysergic-acid
  • 19,570
  • 21
  • 109
  • 218