clr

Where can I find location of generated file after doing Ngen?

非 Y 不嫁゛ 提交于 2019-11-27 12:14:08
问题 I did Ngen on a C# executable. It was succesful, but I cannot figure out where the generated file is in my PC. MSDN says it should be in native image cache, still not able to figure out where it is.. EDIT : I want to run objdump on it, hence I need the physical file EDIT2: my putput of running ngen is : C:\Documents and Settings\nmea\My Documents\Visual Studio 2008\Projects\Consol eApplication4\ConsoleApplication4\bin\Release>ngen install ConsoleApplication4.e xe Microsoft (R) CLR Native

Interface with generic parameter vs Interface with generic methods

限于喜欢 提交于 2019-11-27 11:30:51
问题 Let's say I have such interface and concrete implementation public interface IMyInterface<T> { T My(); } public class MyConcrete : IMyInterface<string> { public string My() { return string.Empty; } } So I create MyConcrete implementation for strings , I can have one more concrete implementation for int . And that's ok. But let's say, that I want to do the same thing, but with generic methods, so I have public interface IMyInterface2 { T My<T>(); } public class MyConcrete2 : IMyInterface2 {

Is MarshalByRefObject special?

只谈情不闲聊 提交于 2019-11-27 11:05:08
问题 .NET has a thing called remoting where you can pass objects around between separate appdomains or even physical machines. I don't fully understand how the magic is done, hence this question. In remoting there are two base ways of passing objects around - either they can be serialized (converted to a bunch of bytes and the rebuilt at the other end) or they can inherit from MarshalByRefObject, in which case .NET makes some transparent proxies and all method calls are forwarded back to the

JIT vs NGen - what is the difference?

本小妞迷上赌 提交于 2019-11-27 10:30:27
问题 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? 回答1: The difference is when they occur. The JIT compilation occurs while your program is running. NGen is a typically done at installation time of your program and happens before your program is run. One of the goals of NGen is to remove the JIT penalty from

Create empty C# event handlers automatically

梦想与她 提交于 2019-11-27 10:19:30
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 ); } I would like to keep my code as clean as possible and get rid of those null checks. I don't think it will affect performance very much, at least not in my case. MyEvent( param1, param2 ); Right now I solve this by adding an empty inline handler to each event manually. This is error prone, since I need to remember to do that etc. void Initialize() { MyEvent += new MyEvent( (p1,p2) => { } ); } Is

Instantiation of recursive generic types slows down exponentially the deeper they are nested. Why?

爱⌒轻易说出口 提交于 2019-11-27 10:17:04
问题 Note: I may have chosen the wrong word in the title; perhaps I'm really talking about polynomial growth here. See the benchmark result at the end of this question. Let's start with these three recursive generic interfaces † that represent immutable stacks: interface IStack<T> { INonEmptyStack<T, IStack<T>> Push(T x); } interface IEmptyStack<T> : IStack<T> { new INonEmptyStack<T, IEmptyStack<T>> Push(T x); } interface INonEmptyStack<T, out TStackBeneath> : IStack<T> where TStackBeneath :

Why does C#/CLR not support method override co/contra-variance?

丶灬走出姿态 提交于 2019-11-27 09:40:50
There are quite a few questions & answers about hacking around the limitation of C# not allowing method return (and argument) types to be changed to compatible types on overrides, but why does this limitation exist, either in the C# compiler or in the CLR? As I an see, there is nothing that could break if co/contra-variance was allowed, so what is the reasoning behind it? A similar question could be asked for widening access parameters - eg overriding a protected internal method with a public method (something which Java supports, IIRC) Robert Kozak Eric Lippert already answered this way

Are there any .NET CLR/DLR implementations of ECMAScript?

拟墨画扇 提交于 2019-11-27 09:22:13
问题 Does anyone know of real (i.. no vaporware) implementations of ECMAScript targeting the .NET CLR/DLR ? Ideally something like what Rhino is for Java . A solid port of Rhino running on .NET Framework / Mono Framework would be perfect. I've only seen a handful of projects mentioned but never seen any come to light or in reality anything that I've ever been able to run script on. Here's what I know about already: MSScriptControl ActiveX Control : AFAIK, this was Microsoft's last real ECMAScript

variable scope in statement blocks

試著忘記壹切 提交于 2019-11-27 09:15:07
for (int i = 0; i < 10; i++) { Foo(); } int i = 10; // error, 'i' already exists ---------------------------------------- for (int i = 0; i < 10; i++) { Foo(); } i = 10; // error, 'i' doesn't exist By my understanding of scope, the first example should be fine. The fact neither of them are allowed seems even more odd. Surely 'i' is either in scope or not. Is there something non-obvious about scope I don't understand which means the compiler genuinely can't resolve this? Or is just a case of nanny-state compilerism? By my understanding of scope, the first example should be fine. Your

Are static indexers not supported in C#? [duplicate]

一个人想着一个人 提交于 2019-11-27 09:11:14
This question already has an answer here: Static Indexers? 7 answers I've been trying this a few different ways, but I'm reaching the conclusion that it can't be done. It's a language feature I've enjoyed from other languages in the past. Is it just something I should just write off? No, static indexers aren't supported in C#. Unlike other answers, however, I see how there could easily be point in having them. Consider: Encoding x = Encoding[28591]; // Equivalent to Encoding.GetEncoding(28591) Encoding y = Encoding["Foo"]; // Equivalent to Encoding.GetEncoding("Foo") It would be relatively