clr

C# - Why does a class, new() constraint use Activator.CreateInstance<T>()? [duplicate]

只愿长相守 提交于 2019-12-10 17:12:11
问题 This question already has answers here : Why does the c# compiler emit Activator.CreateInstance when calling new in with a generic type with a new() constraint? (5 answers) Closed 3 years ago . I just asked C# - How do generics with the new() constraint get machine code generated? After thinking about this for a while, I'm wondering why the C# Compiler emitted IL like that. Why couldn't it say some IL like: "Call T's default constructor"? 回答1: There is no such instruction in CIL (http://www

CLR dependent assembly resolution at startup

无人久伴 提交于 2019-12-10 16:58:59
问题 Does CLR try to resolve [not necessarily load] all the dependent assemblies when the program starts up? That is, is the dependent assembly resolution done on demand? Please note that I am not talking about Assembly.Load* [reflective] kind of load. 回答1: It is the JIT compiler that directs the loading of assemblies, in response to translating IL to machine code. Type method calls are at first translated to call a stub function. When called, this stub activates the JIT compiler to load the IL

Why does collection initializer work with getter-only property?

拟墨画扇 提交于 2019-12-10 16:39:16
问题 It is very unpredictable result of code for me. I did not expect this code to produce such a result. So, I read Jeffrey Richter's book (clr ia c#) and there is a example with this code. internal class ClassRoom { private List<String> _students = new List<string>(); public List<String> Students { get { return _students; } } } ClassRoom classRoom = new ClassRoom { Students = {"Mike", "Johny", "Vlad", "Stas"} }; foreach (var some in classRoom.Students) { Console.WriteLine(some); } And, as some

How to preload .net assemblies

左心房为你撑大大i 提交于 2019-12-10 16:04:54
问题 At my work, we are developing different applications using .net framework 4. All the applications use common assemblies that we developed, for example the data layer in data.dll. These applications reside on a network drive and are launched directly from there. Most big applications take a while, like maybe 4-5 seconds, to launch the first time (cold startup). The subsequent launches are much faster, almost instantaneous. I don't think it has to do with the network, since the biggest assembly

Looking for eval function in any .NET language

前提是你 提交于 2019-12-10 16:02:14
问题 Do any .NET/CLR languages support an eval function and also allow calling into standard .NET code (e.g. calling into C# code)? I know that neither F# nor C# support eval . Are there any other options? I am ideally looking for a solution compatible with .NET 3.5 (so I think this rules out Clojure-CLR), but I'm interested in any/all options. 回答1: JScript.NET has an eval function, see this answer 回答2: An Eval Function for C# using JScript.NET (JavaScript) 回答3: Not sure if this helps, but as you

Why Do I need Econo JIT?

柔情痞子 提交于 2019-12-10 15:46:06
问题 I studied that Econo JIT is not optimized for the environment compiling the IL, different than the Normal JIT. Also, it doesn't create machine code cache for the next execution, which means every time the PE runs, the JIT compiles the IL into machine instructions again. I am confused why would One choose to compile in Econo Jit then. Also, is there a choice of JIT to be chosen in Visual Studio? or should I compile through prompt if I want to choose difference JIT mode? 回答1: The idea of Econo

CLR: Multi Param Aggregate, Argument not in Final Output?

こ雲淡風輕ζ 提交于 2019-12-10 14:51:30
问题 Why is my delimiter not appearing in the final output? It's initialized to be a comma, but I only get ~5 white spaces between each attribute using: SELECT [article_id] , dbo.GROUP_CONCAT(0, t.tag_name, ',') AS col FROM [AdventureWorks].[dbo].[ARTICLE_TAG_XREF] atx JOIN [AdventureWorks].[dbo].[TAGS] t ON t.tag_id = atx.tag_id GROUP BY article_id The bit for DISTINCT works fine, but it operates within the Accumulate scope... Output: article_id | col ---------------------------------------------

Can async-await be available in other .NET languages besides C#?

混江龙づ霸主 提交于 2019-12-10 14:32:45
问题 The async-await pattern is one of the more powerful additions to .NET 4.5 and C# 5.0 It is currently only available in C# and VB as far as I know. Is this API a feature of the .NET CLR or of the C# compiler itself? What I'm really asking is this - should we expect async/await in the other .NET languages such as: C++ (via C++/CLI) Python (via IronPython) PHP (via Phalanger) JavaScript (via IronJS) Please note I'm not asking about asynchronous programming in general, but about the specifics of

How slow is NaN arithmetic in the Intel x64 FPU?

て烟熏妆下的殇ゞ 提交于 2019-12-10 14:29:37
问题 Hints and allegations abound that arithmetic with NaNs can be 'slow' in hardware FPUs. Specifically in the modern x64 FPU, e.g on a Nehalem i7, is that still true? Do FPU multiplies get churned out at the same speed regardless of the values of the operands? I have some interpolation code that can wander off the edge of our defined data, and I'm trying to determine whether it's faster to check for NaNs (or some other sentinel value) here there and everywhere, or just at convenient points. Yes,

CIL unbox_any instruction - strange behavior

為{幸葍}努か 提交于 2019-12-10 14:06:35
问题 .method public static void Test<class T>(object A_0) cil managed { // Code size 13 (0xd) .maxstack 1 .locals init (!!T V_0) IL_0000: ldarg.0 IL_0001: isinst !!T IL_0006: unbox.any !!T IL_000b: stloc.0 IL_000c: ret } // end of method DemoType::Test The equal C# code is: public static void Test<T>(object o) where T : class { T t = o as T; } My questions are: Why unbox.any been called? if you just do var a = father as child isinst intruction will call and no unbox.any, and If i'll remove the