cil

OnExit is not entering via PostSharp in asp.net project.

Hi there, I have setup PostSharp and it appears to be working but i don't get it entering OnExit (i have logged setup to ensure it is working) ... Its a bit tricky to configure with asp.net - or is it just me ... I am using the 1.5 new version I basically have the following in my web.config and i had to add the SearchPath otherwise it...

Passing a lambda to a secondary AppDomain as a stream of IL and assembling it back using DynamicMethod

Is it possible to pass a lambda expression to a secondary AppDomain as a stream of IL bytes and then assemble it back there using DynamicMethod so it can be called? I'm not too sure this is the right way to go in the first place, so here's the (detailed) reason I ask this question... In my applications, there are a lot of cases when I ...

Compiling code directly into MSIL

Hi Is there a way to complie code directly into MSIL rather than Native Code. so that we can bypass JIT while executing the code on machine. If its possible. Please let me know the technique also. Thanks ...

Is it possible to Code in MSIL?

I am just curious to know if this can be done or not. I don't plan on doing it if it dosen't pack some significant performance benefits. I am a web and game developer but I usually don't develop games in c#. ...

I am trying to make an obfuscator.

This is kind of a two part question. But it both relates to the same thing. I want to work with the IL code of an app to apply patches. I am wondering what would be the right approach. Obviously I could decompile it and read and edit the il code file then recompile. but is there some way to read it as msil code right in the file. and ma...

PEVerify Warning Parameter out of Sequence

I've built an assembly using Reflection.Emit. Running PEVerify returns 214 warnings of the same type: [MD]: Warning: Parameter out of sequence (parameter: 1; seq.num: 1). [token:0x06000171] Unfortunately there isn't much documentation around these sort of issues. I'm guessing because it's a metadata warning it's something to do with ...

MSIL Question (Basic)

Well lets say we have this c# code: public override void Write(XDRDestination destination) { destination.WriteInt(intValue); destination.WriteBool(boolValue); destination.WriteFixedString(str1, 100); destination.WriteVariableString(str2, 100); } IL: .method public hidebysig virtual instance void Write(class [...

Is it possible to skip visibility checks when generating dynamic IL with MethodBuilder's?

When generating IL using DynamicMethod it's possible to call methods and access fields that would be otherwise un-accessible if you provide 'true' for the restrictedSkipVisibility parameter in the DynamicMethod constructor I would prefer to emit dynamic IL into a dynamic assembly instead so I can save the generated IL into an assembly a...

c# ILGenerator nop?

Im generating some IL with the ILGenerator here is my code: DynamicMethod method = new DynamicMethod("test", null, Type.EmptyTypes); ILGenerator gen = method.GetILGenerator(); gen.Emit(OpCodes.Ldarg_0); gen.Emit(OpCodes.Ldarg_1); gen.Emit(OpCodes.Ldc_I4_S, 100); This generated this IL: IL_0000: ldarg.0 IL_0001: ldarg.1 IL_0...

Normalizing .net generics

While rewriting an assembly if I were to instruct a compiler to generate a nongeneric type for each generic instance would the application just get bigger in code and yet have the same performance? ...

Partially disassembling .net executable.

Hello. I need to write a relatively small program to parse .net executables and generate the list of calls to external methods. For example if System.Console.WriteLine is called inside the file the tool should print that System.Console.WriteLine is called somewhere. I cannot (limited brain and time) and need not (all I need is a list of ...

Has the ECMA CIL/Microsoft MSIL specification ever substantially changed?

The ECMA standard for the .NET Common Intermediate Language has been updated three times. I haven't been able to find a version history that would make clear the changes between the versions. Are there any substantial differences between the four, e.g. new opcodes etc.? Also: Is the same true for MSIL? Thank you! ...

Stringbuilder in CIL (MSIL)

Hey there, I'm trying to generate code that takes a StringBuilder, and writes the values of all the properties in a class to a string. I've got the following, but I'm currently getting a "Invalid method token" in the following code: public static DynamicAccessor<T> CreateWriter(T target) //Target class to *serialize* { ...

.NET DynamicMethod Thread Safe?

If I write a DynamicMethod with an ILGenerator and the code that I output is thread safe would the resulting delegate be threadsafe? My concern is that the IL gets compiled the first time the method runs. If that is true what happens if some other thread tries to run the delegate while it is compiling? ...

NOP in release build of F# code

I am playing with F# in VS2010 beta2, and since I am new to F#, I just picked one of the common examples and went ahead and implemented a factorial function as: let rec factorial n = if n <= 1 then 1 else n * factorial (n - 1);; If I build this and look at the generated code in Reflector, I get the corresponding C# code: public sta...

Linking a .NET Expression Tree into a new assembly

I'm trying to write my own toy My Toy Language -> MSIL compiler in order to get a better understanding of how compilers work. I got the parsing and lexing working, I have built the expression trees and using the System.Linq.Expressions expression tree API, I have a working interpreter. Now I would like to emit some real MSIL assemblies. ...

C# compiling to MSIL code

Does the Microsoft C# compiler (CSC.exe) have an option to output the Intermediate Language files? Kind of like the -S switch does in GCC? ...

C# compiler + generic code with boxing + constraints

Let's examine the MSIL code generated for the following generic method: public static U BoxValue<T, U>(T value) where T : struct, U where U : class { return value; } Look: .method public hidebysig static !!U BoxValue<valuetype .ctor ([mscorlib]System.ValueType, !!U) T,class U>(!!T 'value') cil managed { .maxstack 8 IL_00...

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

Do you know any good book about the workings of the CLR, the .NET Framework and CIL as opposed to any specific .NET language? ...

Why do I have to do ldarg.0 before calling a field in MSIL?

I want to call a function, with as parameters a string and an Int32. The string is just a literal, the Int32 should be a field. So I thought it should be something like: .method public hidebysig instance string TestVoid() cil managed { .maxstack 1 .locals init ( [0] string CS$1$0000) L_0000: nop L_0001: ldstr "m...