clr

A definitive guide to API-breaking changes in .NET

放肆的年华 提交于 2019-11-26 02:26:58
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: API change - a change in the publicly visible definition of a type, including any of its public members. This includes changing type and member names, changing base type of a type, adding/removing interfaces from list of implemented interfaces of a type, adding/removing members (including overloads), changing member visibility, renaming method and type parameters, adding default values for method

What are the roots?

泄露秘密 提交于 2019-11-26 02:18:36
问题 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 be a local variable, static variable. I m little confused with discriminating the difference between root and live objects. What is path to root? How does root and live objects work? Can someone elaborate ? 回答1: If you think of the objects in memory as a tree, the "roots" would be the root nodes

Are C# uninitialized variables dangerous?

只谈情不闲聊 提交于 2019-11-26 02:13:47
问题 I\'m familiar with the C# spec, 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 hard to track down bug). But I am under the impression that there are not truly \"unassigned\" values allowed by the runtime. In particular that a reference type that is not initialized will always have a null value, never the value left over from a

A definitive guide to API-breaking changes in .NET

左心房为你撑大大i 提交于 2019-11-26 01:50:30
问题 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: API change - a change in the publicly visible definition of a type, including any of its public members. This includes changing type and member names, changing base type of a type, adding/removing interfaces from list of implemented interfaces of a type, adding/removing members (including

Why Large Object Heap and why do we care?

烈酒焚心 提交于 2019-11-26 01:39:44
问题 I have read about Generations and Large object heap. But I still fail to understand what is the significance (or benefit) of having Large object heap? What could have went wrong (in terms of performance or memory) if CLR would have just relied on Generation 2 (Considering that threshold for Gen0 and Gen1 is small to handle Large objects) for storing large objects? 回答1: A garbage collection doesn't just get rid of unreferenced objects, it also compacts the heap. That's a very important

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

夙愿已清 提交于 2019-11-26 01:29:04
问题 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? 回答1: C# doesn't allow structs to derive from classes Your statement is incorrect, hence your confusion. C# does allow structs to derive from classes. All structs derive from the same class, System.ValueType, which derives from System.Object. And all enums derive from System.Enum. UPDATE: There has been some confusion in some (now deleted)

Performance surprise with “as” and nullable types

感情迁移 提交于 2019-11-26 01:11:14
问题 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 (x.HasValue) { ... // Use x.Value in here } I thought this was really neat, and that it could improve performance over the C# 1 equivalent, using \"is\" followed by a cast - after all, this way we only need to ask for dynamic type checking once, and then a simple value check. This appears not

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

自作多情 提交于 2019-11-25 22:06:57
问题 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 the same object. Why isn\'t string just a value type then? 回答1: Strings aren't value types since they can be huge, and need to be stored on the heap. Value types are (in all implementations of the CLR as of yet) stored on the stack. Stack allocating strings would break all sorts of things: the

Deciphering the .NET clr20r3 exception parameters P1..P10

≡放荡痞女 提交于 2019-11-25 21:50:01
问题 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 is: P1 : the hosting process ( e.g. w3wp.exe ) P2 : the hosting process version ( e.g. 6.0.3790.1830 ) P3 : ??? ( e.g. 42435be1 ) P4 : the assembly from which the exception was raised ( e.g. mrtables.webservice ) P5 : the assembly version ( e.g. 2.1.2.0 ) P6 : ??? ( e.g. 4682617f ) P7 : ??? ( e

Casting vs using the 'as' keyword in the CLR

与世无争的帅哥 提交于 2019-11-25 21:43:58
问题 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 does this affect my program? public interface IMyInterface { void AMethod(); } public class MyClass : IMyInterface { public void AMethod() { //Do work } // Other helper methods.... } public class Implementation { IMyInterface _MyObj; MyClass _myCls1; MyClass _myCls2; public Implementation() {