clr

How does the C# garbage collector find objects whose only reference is an interior pointer?

南笙酒味 提交于 2019-11-28 19:39:18
In C#, ref and out params are, as far as I know, passed by passing only the raw address of the relevant value. That address may be an interior pointer to an element in an array or a field within an object. If a garbage collection occurs, it's possible that the only reference to some object is through one of these interior pointers, as in: using System; public class Foo { public int field; public static void Increment(ref int x) { System.GC.Collect(); x = x + 1; Console.WriteLine(x); } public static void Main() { Increment(ref new Foo().field); } } In that case, the GC needs to find the

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

∥☆過路亽.° 提交于 2019-11-28 19:21:55
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 Image Generator - Version 2.0.50727.3053 Copyright (c) Microsoft Corporation. All rights reserved.

.Net 4.0 Windows Application crashes in clr.dll under Windows Server 2008

青春壹個敷衍的年華 提交于 2019-11-28 18:37:39
I have a Windows application scheduled to run on a daily basis and fails intermittently due to the following log in EventViewer. Faulting application name: MyApplication.exe, version: 1.0.0.0, time stamp: 0x4d54829a Faulting module name: clr.dll, version: 4.0.30319.1, time stamp: 0x4ba21eeb Exception code: 0xc0000005 Fault offset: 0x00000000000029e1 Faulting process id: 0xbb1c Faulting application start time: 0x01cbd99223d8b4eb Faulting application path: E:\MyApplication\MyApplication.exe Faulting module path: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll Report Id: 7e74ec7e-45a5

Interface with generic parameter vs Interface with generic methods

白昼怎懂夜的黑 提交于 2019-11-28 18:37:27
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 { public string My<string>() { throw new NotImplementedException(); } } So I have the same IMyInterface2 ,

Why doesn't the CLR always call value type constructors

南楼画角 提交于 2019-11-28 18:34:01
问题 I have a question concerning type constructors within a Value type . This question was inspired by something that Jeffrey Richter wrote in CLR via C# 3rd ed, he says (on page 195 - chapter 8) that you should never actually define a type constructor within a value type as there are times when the CLR will not call it. So, for example (well...Jeffrey Richters example actually), I can't work out, even by looking at the IL, why the type constructor is not being called in the following code:

Is MarshalByRefObject special?

淺唱寂寞╮ 提交于 2019-11-28 18:08:47
.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 original instance. This is pretty cool and works like magic. And I don't like magic in programming. Looking

Managed C++ to form a bridge between c# and C++

回眸只為那壹抹淺笑 提交于 2019-11-28 18:02:10
I'm a bit rusty, actually really rusty with my C++. Haven't touched it since Freshman year of college so it's been a while. Anyway, I'm doing the reverse of what most people do. Calling C# code from C++. I've done some research online and it seems like I need to create some managed C++ to form a bridge. Use __declspec(dllexport) and then create a dll from that and use the whole thing as a wrapper. But my problem is - I'm really having a hard time finding examples. I found some basic stuff where someone wanted to use the C# version to String.ToUpper() but that was VERY basic and was only a

JIT vs NGen - what is the difference?

回眸只為那壹抹淺笑 提交于 2019-11-28 17:14:16
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? 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 application start up. JIT is only done per-method; it doesn't JIT everything... Only the bits you need. Of

CLR implementation of virtual method calls to interface members

落花浮王杯 提交于 2019-11-28 16:32:22
Out of curiosity: how does the CLR dispatch virtual method calls to interface members to the correct implementation? I know about the VTable that the CLR maintains for each type with method slots for each method, and the fact that for each interface it has an additional list of method slots that point to the associated interface method implementations. But I don't understand the following: how does the CLR efficiently determine which interface method slot list to pick from the type's VTable? The article Drill Into .NET Framework Internals to See How the CLR Creates Runtime Objects from the May

Clojure on the CLR

╄→尐↘猪︶ㄣ 提交于 2019-11-28 16:12:11
问题 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 original). I'd less inclined to spend much time at this point if generally people find Clojure on the CLR immature--I simply don't have the time or energy to fight a bunch of problems at this point. On the other hand, if Clojure on the CLR seems well-baked, I'd start diving in today! Has anyone