cil

CIL, CLS, and CTS in .NET

北城余情 提交于 2019-12-29 06:54:12
问题 What is the CIL, CTS, and CLS in .NET and what is the difference between them? 回答1: CIL (Common Intermediate Language) is the byte code to which your C# or Visual Basic code is compiled. It's the "machine code" of the .NET execution engine. The CTS (Common Type System) is the representation of types (classes and structures) at the compiled level. Basically, it's saying that all .NET languages will use a common way of representing types (classes and structures). The CLS (Common Language

Converting IL to C# with no syntactic sugar

老子叫甜甜 提交于 2019-12-25 00:50:48
问题 I'm looking for a program that will show me the lowest level (ie. no syntactic sugar) C# code given IL code. I tried using .NET Reflector to view a .exe file that contained a simple console app with a foreach loop, hoping to see GetEnumerator() , MoveNext() , Current etc, however it showed it as a foreach loop. Does such a program exist? Or is it possible to select "no syntactic sugar" in .NET Reflector? 回答1: Current versions of ILSpy have a sizable set of options for enabling/disabling

What does the IL “.custom instance void [attribute] = (…)” mean?

强颜欢笑 提交于 2019-12-24 12:07:48
问题 When I used the params keyword for a parameter I found this line in the IL. What I understood from this is that a constructor of the ParamArrayAttribute class is called but I didn't understand what 01 00 00 00 means. .custom instance void [mscorlib]System.ParamArrayAttribute::.ctor() = ( 01 00 00 00 ) 回答1: Please refer to section II.21 of the C# specification (version 6) defined in ECMA-335: Custom attributes are declared using the directive .custom, followed by the method declaration for a

CIL: “Operation could destabilize the runtime” exception

蹲街弑〆低调 提交于 2019-12-24 07:28:07
问题 I've been playing with PostSharp a bit and I ran into a nasty problem. Following IL in Silverlight assembly: .method public hidebysig specialname newslot virtual final instance void set_AccountProfileModifiedAt(valuetype [mscorlib]System.DateTime 'value') cil managed { .maxstack 2 .locals ( [0] bool ~propertyHasChanged, [1] bool CS$4$0000) L_0000: nop L_0001: nop L_0002: ldarg.0 L_0003: call instance valuetype [mscorlib]System.DateTime Accounts.AccountOwner::get_AccountProfileModifiedAt() L

How does Reflector decompile code?

半城伤御伤魂 提交于 2019-12-24 07:03:20
问题 How do tools like the Red Gate Ant Profiler or the Reflector convert IL into C# or VB.NET code? I recently noticed that the Red Gate Ant Profiler does not generate the same source code that was written originally. It generated a while loop where I had used a foreach . That made me think. I opened Reflector.exe itself in Reflector but their code is mostly (not all of it) obfuscated. 回答1: Decompilers in general work by looking at the IL and constructing source code which is semantically

prevent DynamicMethod VerificationException - operation could destabilize the runtime

删除回忆录丶 提交于 2019-12-24 04:06:48
问题 I am using IL generation to create a simple deserializer method which takes strings out of a Lucene document and sets properties or fields of a reference-type object (POCO). Whenever I try to run the generated method, I receive a VerificationException error. There are other questions regarding this error, a few of which have to do with DynamicMethods, but from what I can tell the issue I am having is different. operation-could-destablize-the-runtime-and-dynamicmethod-with-value-types msil

Stuck with ILIDE

不羁岁月 提交于 2019-12-24 00:42:47
问题 I'm trying desperately to find a (good, even any?) IDE for MSIL. (For that c : IDE for MSIL) I thought I found one with ILIDE, but when debugging my code I always (it's not depending on the code) get : SandDock]TD.SandDock.ControlLayoutSystem::OnMouseMove(System.Windows.Forms.MouseEventArgs When I don't use the mouse (since it's apparently triggered by e mouse-over) I get : System.NullReferenceException from 'debugger 3' without any additional info. Anyone used the program (3.0) with more

Is a 'With … End With' really more efficient?

青春壹個敷衍的年華 提交于 2019-12-23 12:13:40
问题 So I'm playing with ILDASM and noticed an oddity that I can't find a really good explanation for on Google. It seems that when using With blocks in VB.NET, the resulting MSIL larger than w/o. So this leads me to ask, are With Blocks really more efficient? MSIL is what gets JITed into native machine code, so smaller code size should imply more efficient code, right? Here's a sample of two classes (Class2 and Class3), which set the same values for an instance of Class1. Class2 does it without a

Where can I get Mono.Cecil.Pdb.dll?

会有一股神秘感。 提交于 2019-12-23 10:55:12
问题 I'm trying to write a IL Weaver with Mono.Cecil, and for it to remain debugable in VS2010, I need the PdbReaderProvider class, or some similar implementation of ISymbolProvider. I've downloaded the latest Mono dlls from http://mono.ximian.com/daily/, but in the zip there is no Mono.Cecil.Pdb.dll. I've downloaded the source code from https://github.com/jbevain/cecil/tree/master/Mono.Cecil but I can't seem to be able to get that particular project compile under .net 4. Could somebody help me

Are Bytecode and Assembly Language the same thing?

点点圈 提交于 2019-12-23 08:25:51
问题 The question might seem odd, but I am still trying to grasp the concepts of virtual machines. I have read several answers, but I still don't get if Java bytecode (and MSIL as well) is the same as assembly language. As far as I understand both bytecode and assembly gets compiled to machine code, so speaking in terms of abstraction they are at the same level, i.e. one step above machine code. So is bytecode just an assembly language, i.e. a human readable form of machine code. If yes, then why