clr

Loader lock (regsvr32 R6033 error) with managed C++ dll

老子叫甜甜 提交于 2020-01-01 15:04:14
问题 I have a C++ dll which implements several COM interfaces, that I'm trying to migrate to managed C++. I set the /clr compiler flag and changed the Runtime Library property from /MT to /MD to avoid the conflict between these two flags, but that's all I've changed. When it attempts to register the dll during the build process, I get the following error: R6033 - Attempt to use MSIL code from this assembly during native code initialization This indicates a bug in your application. It is most

How does Marshal.GetFunctionPointerForDelegate work on instance members?

眉间皱痕 提交于 2020-01-01 11:59:07
问题 I am wondering about Marshal.GetFunctionPointerForDelegate. Namely I want to know how it converts a delegate to a function that is non static into a function pointer. Does it dynamically generate a code stub that has the instance attached somehow? And if so, doesn't this leak memory? Perhaps the delegate frees it in its finalizer? It doesn't look like System.Delegate has a finalizer, so I am very interested in how this mechanism works. I would assume that it would take 4 bytes for the

how to read the assembly manifest without loading the .dll

谁都会走 提交于 2020-01-01 11:55:28
问题 Essentially need to read the dependencies programmatically without loading the assembly itself, as then you can't unload them 回答1: 2 solutions come to my mind, although I think there's easier way (which I forgot or don't know :) ): 1. Load your assemblies using some additional AppDomain that you can create. Unloading whole AddDomain will also unload loaded assemblies (but only those, which were loaded using this AppDomain ). 2. Use some api, for example CCI that allows you to look inside

decimal in c# misunderstanding?

霸气de小男生 提交于 2020-01-01 04:38:06
问题 (while trying to analyze how decimal works ) && after reading @jonskeet article and seeing msdn , and thinking for the last 4 hours , I have some questions : in this link they say something very simple : 1.5 x 10^2 has 2 significant figures 1.50 x 10^2 has 3 significant figures. 1.500 x 10^2 has 4 significant figures etc... ok...we get the idea. from jon's article : sign * mantissa / 10^exponent As usual, the sign is just a single bit, but there are 96 bits of mantissa and 5 bits of exponent

GC Behavior and CLR Thread Hijacking

夙愿已清 提交于 2020-01-01 04:18:22
问题 I was reading about the GC in the book CLR via C# , specifically about when the CLR wants to start a collection. I understand that it has to suspend the threads before a collection occurs, but it mentions that it has to do this when the thread instruction pointer reaches a safe point. In the cases where it's not in a safe point, it tries to get to one quickly, and it does so by hijacking the thread (inserting a special function pointer in the thread stack). That's all fine and dandy, but I

In CLR, what is difference between a background and foreground thread?

本秂侑毒 提交于 2020-01-01 04:17:27
问题 What is difference between a background and foreground thread ? 回答1: From MSDN: Background threads are identical to foreground threads with one exception: a background thread does not keep the managed execution environment running. 回答2: See this page: Foreground threads have the ability to prevent the current application from terminating. The CLR will not shut down an application (which is to say, unload the hosting AppDomain) until all foreground threads have ended. Background threads

Books and literature for implementing a language on the CLR [closed]

[亡魂溺海] 提交于 2020-01-01 03:38:05
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 8 years ago . I'm looking for books and literature on the inner workings of the CLR (and/or possibly the DLR), my long time goal is to implement a

hosting clr and catching threading exceptions

醉酒当歌 提交于 2020-01-01 02:04:07
问题 I am trying to write an plugin system that can load managed plugins. The host should be able to unload the plugins if there are any exceptions. for my poc I have a sample code library in C# that throws an exception like this ... public static int StartUp(string arguments) { Console.WriteLine("Started exception thrower with args {0}", arguments); Thread workerThread = new Thread(() => { Console.WriteLine("Starting a thread, doing some important work"); Thread.Sleep(1000); throw new

When does the UnderlyingSystemType differ from the current Type instance

Deadly 提交于 2020-01-01 01:17:54
问题 System.Type contains an UnderlyingSystemType property. MSDN states that it: Indicates the type provided by the common language runtime that represents this type. In most cases, this property simply returns the current Type instance. My question is, in what circumstances does this property not return the current Type instance itself. And in those cases, what sort of type will be the current Type instance and the returned underlying system type be? 回答1: To be honest I never did it by myself,

When does the UnderlyingSystemType differ from the current Type instance

怎甘沉沦 提交于 2020-01-01 01:17:15
问题 System.Type contains an UnderlyingSystemType property. MSDN states that it: Indicates the type provided by the common language runtime that represents this type. In most cases, this property simply returns the current Type instance. My question is, in what circumstances does this property not return the current Type instance itself. And in those cases, what sort of type will be the current Type instance and the returned underlying system type be? 回答1: To be honest I never did it by myself,