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).

clr
Filter by
Sorted by
Tagged with
1635 votes
6 answers
121k views

Try-catch speeding up my code?

I wrote some code for testing the impact of try-catch, but seeing some surprising results. static void Main(string[] args) { Thread.CurrentThread.Priority = ThreadPriority.Highest; Process....
Eren Ersönmez's user avatar
446 votes
12 answers
223k views

In C#, why is String a reference type that behaves like a value type?

A String is a reference type even though it has most of the characteristics of a value type such as being immutable and having == overloaded to compare the text rather than making sure they reference ...
Davy8's user avatar
  • 31.2k
439 votes
16 answers
218k views

Resolving MSB3247 - Found conflicts between different versions of the same dependent assembly

A .NET 3.5 solution ended up with this warning when compiling with msbuild. Sometimes NDepend might help out but in this case it didn't give any further details. Like Bob I ended up having to resort ...
David Gardiner's user avatar
417 votes
18 answers
88k views

Casting vs using the 'as' keyword in the CLR

When programming interfaces, I've found I'm doing a lot of casting or object type conversion. Is there a difference between these two methods of conversion? If so, is there a cost difference or how ...
Frank V's user avatar
  • 25.3k
346 votes
10 answers
37k views

Performance surprise with "as" and nullable types

I'm just revising chapter 4 of C# in Depth which deals with nullable types, and I'm adding a section about using the "as" operator, which allows you to write: object o = ...; int? x = o as int?; if (...
Jon Skeet's user avatar
  • 1.5m
244 votes
18 answers
39k views

A definitive guide to API-breaking changes in .NET

I would like to gather as much information as possible regarding API versioning in .NET/CLR, and specifically how API changes do or do not break client applications. First, let's define some terms: ...
209 votes
7 answers
199k views

What are major differences between C# and Java?

I just want to clarify one thing. This is not a question on which one is better, that part I leave to someone else to discuss. I don't care about it. I've been asked this question on my job interview ...
Enes's user avatar
  • 3,951
173 votes
20 answers
11k views

What can you do in MSIL that you cannot do in C# or VB.NET? [closed]

All code written in .NET languages compiles to MSIL, but are there specific tasks / operations that you can do only using MSIL directly? Let us also have things done easier in MSIL than C#, VB.NET, F#,...
151 votes
3 answers
13k views

What's the cause of this FatalExecutionEngineError in .NET 4.5 beta? [closed]

The sample code below occurred naturally. Suddenly my code thew a very nasty-sounding FatalExecutionEngineError exception. I spent a good 30 minutes trying to isolate and minimize the culprit sample. ...
Gleno's user avatar
  • 16.8k
144 votes
2 answers
49k views

Why is stack size in C# exactly 1 MB?

Today's PCs have a large amount of physical RAM but still, the stack size of C# is only 1 MB for 32-bit processes and 4 MB for 64-bit processes (Stack capacity in C#). Why the stack size in CLR is ...
Nikolay Kostov's user avatar
136 votes
2 answers
4k views

Making your .NET language step correctly in the debugger

Firstly, I apologize for the length of this question. I am the author of IronScheme. Recently I have been working hard on emitting decent debug info, so that I can use the 'native' .NET debugger. ...
leppie's user avatar
  • 116k
126 votes
5 answers
53k views

Why Large Object Heap and why do we care?

I have read about Generations and the Large Object Heap, but I still fail to understand what the significance (or benefit) is of having the Large Object Heap? What could have gone wrong (in terms of ...
Manish Basantani's user avatar
125 votes
4 answers
9k views

Why does struct alignment depend on whether a field type is primitive or user-defined?

In Noda Time v2, we're moving to nanosecond resolution. That means we can no longer use an 8-byte integer to represent the whole range of time we're interested in. That has prompted me to investigate ...
Jon Skeet's user avatar
  • 1.5m
123 votes
8 answers
65k views

C# 'is' operator performance

I have a program that requires fast performance. Within one of its inner loops, I need to test the type of an object to see whether it inherits from a certain interface. One way to do this would be ...
JubJub's user avatar
  • 1,505
123 votes
6 answers
51k views

No AppDomains in .NET Core! Why?

Is there a strong reason why Microsoft chose not to support AppDomains in .NET Core? AppDomains are particularly useful when building long running server apps, where we may want to update the ...
Aditya Pasumarthi's user avatar
117 votes
6 answers
6k views

How many String objects will be created when using a plus sign?

How many String objects will be created when using a plus sign in the below code? String result = "1" + "2" + "3" + "4"; If it was as below, I would have said three String objects: "1", "2", "12". ...
The Light's user avatar
  • 26.7k
102 votes
6 answers
137k views

SQL Server: How to check if CLR is enabled?

SQL Server 2008 - What is an easy way to check if clr is enabled?
magnattic's user avatar
  • 12.8k
99 votes
9 answers
30k views

Implementing C# for the JVM

Is anyone attempting to implement C# for the JVM? As a Java developer, I've been eyeing C# with envy, but am unwilling to give up the portability and maturity of the JVM, not to mention the diverse ...
Rob's user avatar
  • 5,582
98 votes
5 answers
81k views

Float vs Double Performance

I did some timing tests and also read some articles like this one (last comment), and it looks like in Release build, float and double values take the same amount of processing time. How is this ...
Joan Venge's user avatar
  • 323k
94 votes
6 answers
18k views

How do ValueTypes derive from Object (ReferenceType) and still be ValueTypes?

C# doesn't allow structs to derive from classes, but all ValueTypes derive from Object. Where is this distinction made? How does the CLR handle this?
Joan Venge's user avatar
  • 323k
93 votes
5 answers
85k views

ASP.NET CLR Not Enabled

I am getting the following error on my new installation of ASP.Net and SQL Server when I run my app: Execution of user code in the .NET Framework is disabled. Enable "clr enabled" configuration ...
cdub's user avatar
  • 25.1k
84 votes
2 answers
36k views

Deciphering the .NET clr20r3 exception parameters P1..P10

I'm trying to decipher the meaning on the P1...P10 parameters associated with a clr20r3 that is written to the event log when my application experiences an exception. The best I've been able to find ...
Ian Boyd's user avatar
  • 251k
83 votes
8 answers
63k views

Should we always include a default constructor in the class?

I have been asked this question by a colleague that should we always include a default constructor in a class? If so, why? If no, why not? Example public class Foo { Foo() { } Foo(int x, ...
Moon's user avatar
  • 34.2k
81 votes
2 answers
23k views

What is the maximum number of parameters that a C# method can be defined as taking?

I am trying to figure out what the maximum number of parameters a method in C# can have. I've checked everywhere for an answer, including the C# official documentation, MSDN, and a couple of CLR ...
rmiesen's user avatar
  • 2,540
80 votes
4 answers
75k views

Is there a way to get the string representation of HRESULT value using win API?

Is there a function in win API which can be used to extract the string representation of HRESULT value? The problem is that not all return values are documented in MSDN, for example ...
khkarens's user avatar
  • 1,325
78 votes
3 answers
67k views

Size of VARBINARY field in SQL Server 2005

I am trying to determine the size in bytes of the contents in a VARBINARY(MAX) field in SQL Server 2005, using SQL. As I doubt there is native support for this, could it be done using CLR integration? ...
Tewr's user avatar
  • 3,793
78 votes
13 answers
29k views

Why C# is not allowing non-member functions like C++

C# will not allow to write non-member functions and every method should be part of a class. I was thinking this as a restriction in all CLI languages. But I was wrong and I found that C++/CLI supports ...
78 votes
6 answers
50k views

How do I decide whether to use ATL, MFC, Win32 or CLR for a new C++ project?

I'm just starting my first C++ project. I'm using Visual Studio 2008. It's a single-form Windows application that accesses a couple of databases and initiates a WebSphere MQ transaction. I basically ...
John M Gant's user avatar
  • 19.1k
74 votes
8 answers
57k views

Create empty C# event handlers automatically

It is not possible to fire an event in C# that has no handlers attached to it. So before each call it is necessary to check if the event is null. if ( MyEvent != null ) { MyEvent( param1, param2 ); ...
Tomas Andrle's user avatar
  • 13.2k
74 votes
6 answers
9k views

Why check this != null?

Occasionally I like to spend some time looking at the .NET code just to see how things are implemented behind the scenes. I stumbled upon this gem while looking at the String.Equals method via ...
Brian Gideon's user avatar
  • 48.3k
72 votes
5 answers
29k views

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 ...
DarthVader's user avatar
  • 54.1k
70 votes
5 answers
41k views

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 "...
cubetwo1729's user avatar
  • 1,496
67 votes
7 answers
35k views

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 ...
this. __curious_geek's user avatar
64 votes
3 answers
2k views

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 ...
Alexandr Nikitin's user avatar
63 votes
7 answers
46k views

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 ...
Naveen's user avatar
  • 75.6k
62 votes
7 answers
47k views

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 ...
Evereq's user avatar
  • 1,671
61 votes
8 answers
57k views

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 ...
urini's user avatar
  • 32.7k
59 votes
4 answers
26k views

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 ...
Scott Dorman's user avatar
  • 42.4k
58 votes
4 answers
42k views

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.
user avatar
57 votes
4 answers
25k views

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 ...
jeffora's user avatar
  • 4,089
54 votes
7 answers
35k views

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 ...
Ted Smith's user avatar
  • 9,525
54 votes
4 answers
84k views

Interface with generic parameter vs Interface with generic methods

Let's say I have such interface and concrete implementation public interface IMyInterface<T> { T My(); } public class MyConcrete : IMyInterface<string> { public string My() { ...
Jevgenij Nekrasov's user avatar
54 votes
3 answers
8k views

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 ...
Kevin Won's user avatar
  • 7,176
53 votes
6 answers
35k views

.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's user avatar
  • 12.3k
52 votes
5 answers
48k views

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(...
Bashir Magomedov's user avatar
50 votes
5 answers
26k views

Get Current .NET CLR version at runtime?

How can I get the current CLR Runtime version in a running .NET program ?
driis's user avatar
  • 163k
49 votes
7 answers
37k views

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's user avatar
  • 1,299
49 votes
6 answers
14k views

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 ...
Dirk Vollmar's user avatar
49 votes
6 answers
13k views

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 ...
smwikipedia's user avatar
  • 63.1k
48 votes
7 answers
36k views

"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 ...
user626528's user avatar
  • 14.1k

1
2 3 4 5
80