clr

Auto implemented interfaces in Arrays

六月ゝ 毕业季﹏ 提交于 2020-01-03 09:42:04
问题 I read a book "CLR via C# Fourth Edition". And I cannot understand one statement: So, for example, if you have the following line of code: FileStream[] fsArray; then when the CLR creates the FileStream[] type, it will cause this type to automatically implement the IEnumerable<FileStream> , ICollection<FileStream> , and IList<FileStream> interfaces. Furthermore, the FileStream[] type will also implement the interfaces for the base types: IEnumerable<Stream> , IEnumerable<Object> , ICollection

Can I prevent the CLR from optimizing away debugging information?

旧巷老猫 提交于 2020-01-03 09:07:12
问题 I've written an abstract base class for unit tests that sets up just enough environment for our tests to run. The class exposes some of the runtime environment bits as properties whose types vary test by test (the property types are type arguments specified in the inheriting, concrete test class). This is all well and good, except a co-worker noticed that he can't view any of the class' properties in the debugger. Turns out the reason is that he had no fields defined in his inheriting class,

StringBuilder growing over 85k and moving to LOH? [duplicate]

旧时模样 提交于 2020-01-03 03:00:10
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: How does StringBuilder's capacity change? Let's say a StringBuilder is allocated and then it grows to over 85k, will it get moved over to the Large Object Heap? 回答1: StringBuilder doesn't "grow". In pre-4.0 SB, it simply allocated a new bigger buffer and copied the content from the old to the new. So in the end yes, the internal buffer was moved to LOH. The SB object not, because it's very small (to make it

Does implicit operator have higher priority over ToString() method? [duplicate]

早过忘川 提交于 2020-01-02 05:22:09
问题 This question already has an answer here : Order of implicit conversions in c# (1 answer) Closed last year . Consider the following code: public class Test { public static implicit operator int(Test t) { return 42; } public override string ToString() { return "Test here!"; } } var test = new Test(); Console.WriteLine(test); // 42 Console.WriteLine((Test)test); // 42 Console.WriteLine((int)test); // 42 Console.WriteLine(test.ToString()); // "Test here!" Why in the first three cases we have

“Failure loading DAC: CreateDacInstance failed” when loading dump file with ClrMD

那年仲夏 提交于 2020-01-02 03:48:24
问题 I'm trying the new library from microsoft, ClrMD, to analyze crash-dumps and live process. I've follow the sample in the .NET framework blog post (using the attached .cs file). I tried to run the sample to analyze .dmp file which was taken from a program running on the same machine as the sample. when trying to create the run-time object, using the following code: ClrRuntime runtime = target.CreateRuntime(dacLocation); This exception is thrown: Message: Failure loading DAC: CreateDacInstance

“Failure loading DAC: CreateDacInstance failed” when loading dump file with ClrMD

巧了我就是萌 提交于 2020-01-02 03:48:07
问题 I'm trying the new library from microsoft, ClrMD, to analyze crash-dumps and live process. I've follow the sample in the .NET framework blog post (using the attached .cs file). I tried to run the sample to analyze .dmp file which was taken from a program running on the same machine as the sample. when trying to create the run-time object, using the following code: ClrRuntime runtime = target.CreateRuntime(dacLocation); This exception is thrown: Message: Failure loading DAC: CreateDacInstance

What is a cast under the hood [duplicate]

懵懂的女人 提交于 2020-01-02 02:12:42
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: C# “as” cast vs classic cast I want to know what happens under the hood of the .Net CLR when I do something like object myObj = "abc"; string myStr = (string)myObj; and how the second line differs from string myStr = myObj.ToString() or string myStr = myObj as string; looking around I found generics answers such as "the compiler inserts code there" but I'm not satisfied... I'm looking for deep undertanding of

How is .NET JIT compilation performance (including dynamic methods) affected by image debug options of C# compiler?

落爺英雄遲暮 提交于 2020-01-02 00:41:10
问题 I am trying to optimize my application for for it to perform well right after it is started. At the moment, its distribution contains 304 binaries (including external dependencies) totaling 57 megabytes. It is a WPF application doing mostly database access, without any significant calculations. I discovered that the Debug configuration offers way better (~5 times gain) times for most operations, as they are performed for the first time during the lifetime of the application's process. For

Unexpected behavior of Substring in C# [duplicate]

对着背影说爱祢 提交于 2020-01-01 23:14:13
问题 This question already has answers here : Surprising Substring behavior (4 answers) Closed 4 years ago . The definition of Substring() method in .net System.String class is like this public string Substring(int startIndex) Where startIndex is "The zero-based starting character position of a substring in this instance" as per the method definition. If i understand it correctly, it means it will give me a part of the string, starting at the given zero-based index. Now, if I have a string "ABC"

CLR cannot create .NET-based COM objects in UWP

a 夏天 提交于 2020-01-01 19:46:33
问题 I have created a Class Library (.NET Framework 4.7.1) that implements a Text Service ( ITfTextInputProcessorEx etc.) in TSF, using ComVisible attribute. I registered it using RegistrationServices and it can be successfully recognised by the system as an Input Method (IME) and can be used in most applications, except UWP apps. Using in Win32 app In a Win32 app (the 32-bit notepad.exe for example), here is what happens when I activate my .NET-based TextService (by switching to the IME in the