clr

How to run CLR 2 application as CLR 4 application

怎甘沉沦 提交于 2019-12-09 05:45:07
问题 Lets say I have an old application which will try to load an external assembly. The old application is compiled to CLR 2. The new assembly is compiled to CLR 4. I would like to be able to run that old application inside CLR 4. I remember there was some xml manifest magic involved. How can I create that manifest xml file to tell that oldapplication.exe shall run under CLR 4? I found some suggestions, but they do not seem to work for me. http://www.mibuso.com/forum/viewtopic.php?f=23&t=33840

how are C# object references represented in memory / at runtime (in the CLR)?

本小妞迷上赌 提交于 2019-12-09 05:18:46
问题 I'm curious to know how C# object references are represented in memory at runtime (in the .NET CLR). Some questions that come to mind are: How much memory does an object reference occupy? Does it differ when defined in the scope of a class vs the scope of a method? Does where it live differ based on this scope (stack vs heap)? What is the actual data maintained within an object reference? Is it simply a memory address that points to the object it refers to or is there more to it? Does this

My 32 bit headache is now a 64bit migraine?!? (or 64bit .NET CLR Runtime issues)

扶醉桌前 提交于 2019-12-09 04:10:35
问题 What unusual, unexpected consequences have occurred in terms of performance, memory, etc when switching from running your .NET applications under the 64 bit JIT vs. the 32 bit JIT? I'm interested in the good, but more interested in the surprisingly bad issues people have run into. I am in the process of writing a new .NET application which will be deployed in both 32bit and 64bit. There have been many questions relating to the issues with porting the application - I am unconcerned with the

Why does the String class not have a parameterless constructor?

ぃ、小莉子 提交于 2019-12-09 02:33:02
问题 int and object have a parameterless constructor. Why not string ? 回答1: Update: To provide more information for you. You don't have an empty Constructor with a string , however you do have String.Empty . The reason is because a string is an immutable object every instance of a string you modify is actually creating a new string in memory. For instance: string name = ""; though it is an empty string it will still hold around twenty bytes . Where the string.Empty will only hold around four or

Why is ToUpperInvariant() faster than ToLowerInvariant()?

无人久伴 提交于 2019-12-08 20:48:55
问题 I read in CLR via C# by Jeffrey Richter that String.ToUpperInvariant() is faster than String.ToLowerInvariant() . He says that this is because the FCL uses ToUpperInvariant to normalise strings, so the method is ultra-optimised. Running a couple quick tests on my machine, I concur that ToUpperInvariant() is indeed slightly faster. My question is if anybody knows how the function is actually optimised on a technical level, and/or why the same optimisations were not applied to ToLowerInvariant(

How to partition a LINQ to Objects query?

谁说我不能喝 提交于 2019-12-08 17:25:06
问题 This is a resource-allocation problem. My goal is to run a query to fetch the top-priority shift for any time-slot. The dataset is very large. For this example, let’s say there are 100 shifts each for 1000 companies (though the real dataset is even larger). They are all loaded into memory, and I need to run a single LINQ to Objects query against them: var topShifts = (from s in shifts where (from s2 in shifts where s2.CompanyId == s.CompanyId && s.TimeSlot == s2.TimeSlot orderby s2.Priority

Memory Heap Security: String garbage collection

我与影子孤独终老i 提交于 2019-12-08 17:19:15
问题 I have recently been doing a security code review for my company and using a tool called Fortify360. It will identify many issues with the code and describe the problems. An interesting issue it has raised that I have not found any other info on is the following: "Sensitive data (such as passwords) stored in memory can be leaked if it is stored in a managed String object. String objects are not pinned, so the garbage collector can relocate these objects at will and leave several copies in

Unmanaged to managed callback much slower when target is in another AppDomain

时间秒杀一切 提交于 2019-12-08 16:56:50
问题 I'm calling managed code from unmanaged code using a delegate. When I call into managed code in the default AppDomain I'm measuring an average of 5.4ns per call. When I calling to a second AppDomain I'm measuring 194ns per call. (default VS2017 x86 release configuration, not running under the debugger). Why is performance so much lower when calling into an AppDomain that isn't the default? Since I'm coming from the unmanaged side, which has no knowledge of AppDomains I would expect to be

C# Switch/case share the same scope? [duplicate]

半腔热情 提交于 2019-12-08 16:16:38
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Variable declaration in c# switch statement I've always wonderd : when i write : switch (temp) { case "1": int tmpInt = 1; break; } the case "1": region has a region of code which is executed ( until break) now , a waterfall from above can't get into a case of 2 e.g. : switch (temp) { case "1": int tmpInt = 1; case "2": break; } //error : break return is missing. So i assume , they have different regions of

Why are declarations necessary

▼魔方 西西 提交于 2019-12-08 15:00:36
问题 I am currently teaching a colleague .Net and he asked me a question that stumped me. Why do we have to declare? if var is implicit typing, why do we have to even declare? Animal animal = new Animal(); becomes var animal = new Animal(); could become animal = new Animal(); The implicit typing would still mean that this is a statically typed variable. If two different types are assigned to the variable, if they do not share a base class, (other than object), that could be a compiler error. Is