clr

How to test if numeric conversion will change value?

帅比萌擦擦* 提交于 2019-12-04 13:59:56
I'm performing some data type conversions where I need to represent uint , long , ulong and decimal as IEEE 754 double floating point values. I want to be able to detect if the IEEE 754 data type cannot contain the value before I perform the conversion. A brute force solution would be to wrap a try-catch around a cast to double looking for OverflowException . Reading through certain of the CLR documentation implies that some conversions just silently change the value without any exceptions. Is there any fool proof way to do this check? I'm looking for completeness over ease of implementation.

Is mscorlib.dll a CLR?

眉间皱痕 提交于 2019-12-04 13:16:31
问题 If it's not which I almost sure in, then what's the role of mscorlib.dll and where CLR is situated? 回答1: CLR is not in mscorlib.dll but in MSCorEE.dll . I think that is what you were looking for. This is the main DLL loaded when an .NET exe assembly gets loaded. See this question which probably answers you question. 回答2: I believe this question covers most of what you're asking: mscorlib.dll & System.dll 回答3: mscorlib.dll is holding some fundamental classes of .net such as system. use

How the CLR locates pdb symbol files

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 12:06:14
问题 I would like to know how the CLR locates pdb symbol files, and if this behavior can be overridden. I looked online (MSDN and other resources) but could not find a good answer. In my app, i have DLLs placed in several subdirectories of the main .EXE path. I would like to have a Symbols\ dir that will contain all symbols for my application. By default, i believe that symbols are picked up from where the assembly is. Can this be changed? 回答1: You could simply set the _NT_SYMBOL_PATH environment

How to load CLR into process

不问归期 提交于 2019-12-04 11:43:32
I have some question which puzzled me for a long time. What is the relationship between CLR and one process created by OS? What steps the CLR is loaded when we double-click an "Console Application" or "Windows Forms Application"? I found two methods: _CorExeMain() and _CorBindToRuntimeEx(). What's the role of them? Please see Hosting the Common Language Runtime , Loading the Common Language Runtime into a Process , _CorExeMain Function , CorBindToRuntimeEx Function . I think the basic answer is, the CLR must run in a process (host). If you "double-click", a process is created (initally purely

Does the CLR perform “lock elision” optimization? If not why not?

倾然丶 夕夏残阳落幕 提交于 2019-12-04 11:37:54
问题 The JVM performs a neat trick called lock elision to avoid the cost of locking on objects that are only visible to one thread. There's a good description of the trick here: http://www.ibm.com/developerworks/java/library/j-jtp10185/ Does the .Net CLR do something similar? If not then why not? 回答1: It's neat, but is it useful? I have a hard time coming up with an example where the compiler can prove that a lock is thread local. Almost all classes don't use locking by default, and when you

Are static methods eagerly compiled (JIT'ed)?

走远了吗. 提交于 2019-12-04 11:19:00
问题 Per my understanding, both instance methods and static methods are treated same by CLR compiler and the IL code is JITted whenever the method is called first time. Today I had a discussion with my colleague and he told me that the static methods are not treated the same way as instance methods. i.e. Static methods are JITted as soon as the assembly is loaded into application domain whereas instance methods are JITted as they are called for the first time. I am actually confused and do not see

Managed class with a non-managed member

China☆狼群 提交于 2019-12-04 11:15:35
I'm using this class: public ref class x: public System::Windows::Forms::Form { private: gcroot<std::string> name; } and i am getting the following error: IntelliSense: a member of a managed class cannot be of a non-managed class type I know i can use char* , but if I use lots of char* i will have to manually do the delete[] or some heap corruption issues will rise I've been stuck on this for two days now note: I have to use c++ and have to use UI in c++ That's the wrong usage for gcroot<>, you only need that if you keep a reference to a managed object in an unmanaged class. In this case you

Examples of CLR compiler optimizations

て烟熏妆下的殇ゞ 提交于 2019-12-04 10:59:20
I'm doing a presentation in few months about .Net performance and optimization, I wanted to provide some samples of unnecessary optimization, things that will be done by the compiler anyways. where can I find some explanation on what optimizations the compiler is actually capable of maybe some before and after code? check out these links C# Compiler Optimizations compiler optimization msdn Also checkout this book on MSIL 1. Microsoft Intermediate Language: Comparison Between C# and VB.NET / Niranjan Kumar What I think would be even better than examples of "things that will be done by the

How does Marshal.GetFunctionPointerForDelegate work on instance members?

五迷三道 提交于 2019-12-04 10:41:34
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 function pointer and 4 bytes for the instance (on 32-bit), yet it returns a simple IntPtr. Big question,

BOO Vs IronPython

爱⌒轻易说出口 提交于 2019-12-04 10:11:37
问题 What is the difference between IronPython and BOO? Is there a need for 2 Python-like languages? 回答1: IronPython is designed to be a faithful implementation of Python on the .NET platform. Version 1 targets Python 2.4 for compatibility, and version 2 targets version 2.5 (although most of the Python standard library modules implemented in C aren't supported). Boo's stated aim is to be a "wrist-friendly [dynamic] language for the CLI." It takes a lot of inspiration from Python, but diverges on