clr

Why are static classes considered “classes” and “reference types”?

不想你离开。 提交于 2019-12-31 08:57:30
问题 I’ve been pondering about the C# and CIL type system today and I’ve started to wonder why static classes are considered classes. There are many ways in which they are not really classes: A “normal” class can contain non-static members, a static class can’t. In this respect, a class is more similar to a struct than it is to a static class, and yet structs have a separate name. You can have a reference to an instance of a “normal” class, but not a static class (despite it being considered a

Delegates with same signature

∥☆過路亽.° 提交于 2019-12-30 18:39:01
问题 My question is a bit similar to this one: How to convert an action to a defined delegate of the same signature? Why there is no implicit convertion between delegates with same signature. For example, code: class Program { private delegate void Foo1(int x); private delegate void Foo2(int x); static void Main(string[] args) { Foo1 foo1 = Console.WriteLine; Foo2 foo2 = Console.WriteLine; Call(foo1); Call2(foo2); } static void Call(Action<int> action) { action(10); } static void Call2(Foo1 action

Fork Concept in C#

做~自己de王妃 提交于 2019-12-30 17:23:24
问题 Since C# supports threading, is there any way to implement fork concept in C#? Thanks in advance.... 回答1: This is more a matter of .NET / CLR than of C#. Generally, it's a matter of the underlying operating system. Windows do not support fork() -like semantics of spawning new processes. Also, fork() has nothing to do with multithreading support. The semantics of fork() involves duplicating the contents of the original process's address space. My opinion is this is an obsolete approach to

CorFlags.exe, System.Data.SQLite.dll and BadImageFormatException

荒凉一梦 提交于 2019-12-30 10:00:54
问题 Running CorFlags.exe against System.Data.SQLite.dll from http://sqlite.phxsoftware.com/ produces the following output. Version : v2.0.50727 CLR Header: 2.5 PE : PE32 CorFlags : 24 ILONLY : 0 32BIT : 0 Signed : 1 As you can see, 32BIT is not specified and PE is equal to PE32 . According to Moving from 32-bit to 64-bit application development on .NET Framework , this means that the assembly is Any CPU . However, using the assembly from a 64 bit application results in an error: System

Thread order execution?

血红的双手。 提交于 2019-12-30 09:42:09
问题 I have this simple code : ( which i run in linqpad ) void Main() { for ( int i=0;i<10;i++) { int tmp=i; new Thread (() =>doWork(tmp)).Start(); } } public void doWork( int h) { h.Dump(); } the int tmp=i; line is for capture variable - so each iteration will have its own value. 2 problems : 1) the numbers are not sequential , while thread execution is ! 2) sometimes i get less than 10 numbers ! here are some executions outputs: questions : 1) why case 1 is happening and how can i solve it ? 2)

Thread order execution?

拟墨画扇 提交于 2019-12-30 09:41:09
问题 I have this simple code : ( which i run in linqpad ) void Main() { for ( int i=0;i<10;i++) { int tmp=i; new Thread (() =>doWork(tmp)).Start(); } } public void doWork( int h) { h.Dump(); } the int tmp=i; line is for capture variable - so each iteration will have its own value. 2 problems : 1) the numbers are not sequential , while thread execution is ! 2) sometimes i get less than 10 numbers ! here are some executions outputs: questions : 1) why case 1 is happening and how can i solve it ? 2)

How to get current value of EIP in managed code?

帅比萌擦擦* 提交于 2019-12-30 08:39:47
问题 The question seems like a dirty hack you should not do but let me explain first. The ultimate goal is to have method local statics like in C++. void Func() { static methodLocalObject = new ExpensiveThing(); // use methodlocal Object } What has this to do with the instruction pointer? I want to cache data depending on my caller. To make this fast I walk back in the stack to get the address of my caller and use this as unique key for a dictionary to store the data. That would allow to create a

What is your recommendation for a good book on the .NET CLR and CIL? [closed]

倾然丶 夕夏残阳落幕 提交于 2019-12-30 04:44:10
问题 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 7 years ago . Do you know any good book about the workings of the CLR, the .NET Framework and CIL as opposed to any specific .NET language? 回答1:

Interpreting JavaScript outside of the browser?

荒凉一梦 提交于 2019-12-30 00:31:10
问题 This is more out of curiosity that a real requirement, but I'm wondering if it's possible to treat JavaScript as (ideally) a first-class .NET citizen, or (secondarily) have some way of invoking/interpreting pure JavaScript functions (that don't require the DOM) in a desktop setting? Has anyone ever attempted implementing a CLR version of JavaScript? Something tugs at the back of my mind concerning this, but now that I think about it it was probably PHP, not JavaScript. 回答1: For your second

Alignment of arrays in .NET

有些话、适合烂在心里 提交于 2019-12-29 07:43:07
问题 Are arrays in .NET aligned to any boundary? If yes, to which? And is it the same for all array types? 回答1: The common language infrastructure (ECMA-335) places the following restrictions on alignment: 12.6.2 Alignment Built-in data types shall be properly aligned, which is defined as follows: 1-byte, 2-byte, and 4-byte data is properly aligned when it is stored at a 1-byte, 2-byte, or 4-byte boundary, respectively. 8-byte data is properly aligned when it is stored on the same boundary