cil

Can't catch exception inside AIF service

℡╲_俬逩灬. 提交于 2019-12-01 00:31:46
I have created an AIF service in dynamics AX 2012, when I tested it by calling the entrypoint method from a job, it worked fine, but when it is deployed en the calls are comming from the soap UI, it crashes inside with an error: "Unhandled esception". While debugging I found out the unhandled exception is thrown inside my catch clause of my try catch statement. It gets inside the catch because the method I am calling inside the try clause thows an error. So does anyone know why I can catch thrown error when I am running the code on client using the job, but can't catch it while it runs in CIL

Is there a way to count the number of IL instructions executed?

╄→гoц情女王★ 提交于 2019-11-30 22:55:27
I want to do some benchmarking of a C# process, but I don't want to use time as my vector - I want to count the number of IL instructions that get executed in a particular method call. Is this possible? Edit I don't mean static analysis of a method body - I'm referring to the actual number of instructions that are executed - so if, for example, the method body includes a loop, the count would be increased by however many instructions make up the loop * the number of times the loop is iterated. I don't think it's possible to do what you want. This is because the IL is only used during JIT (Just

Indexing arrays with enums in C#

陌路散爱 提交于 2019-11-30 21:53:07
问题 I have a lot of fixed-size collections of numbers where each entry can be accessed with a constant. Naturally this seems to point to arrays and enums: enum StatType { Foo = 0, Bar // ... } float[] stats = new float[...]; stats[StatType.Foo] = 1.23f; The problem with this is of course that you cannot use an enum to index an array without a cast (though the compiled IL is using plain ints). So you have to write this all over the place: stats[(int)StatType.foo] = 1.23f; I have tried to find ways

NOP in release build of F# code

◇◆丶佛笑我妖孽 提交于 2019-11-30 20:36:54
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 static int Factorial(int n) { if (n <= 1) return 1; return n * Factorial(n - 1); } So if I compile Reflector's C# representation of the F# code, I would expect to get identical IL. However, if I compile both of these snippets in release mode and compare the generated IL

What's the different between ldsfld and ldstr in IL?

不打扰是莪最后的温柔 提交于 2019-11-30 19:31:57
I've read some article about String.Empty vs "" and I also do test by my self. Different between them are below. String.Empty L_0001: ldsfld string [mscorlib]System.String::Empty "" L_0001: ldstr "" After I talk with my friends they argue that String.Empty is faster than "" because under the hood (at assembly level) ldstr do more 1 circle than ldsfld. (I can't remember steps that make them different) I want to know how can I check about this aspect of performance. The ldsfld operation pushes the value of a static field onto the evaluation stack, while the ldstr pushes a reference to a meta

Creating a DynamicType in .NET implementing an interface but using member implementations from a base class

牧云@^-^@ 提交于 2019-11-30 18:12:37
I am attempting to generate a dynamic class implementing an interface, but where one or more of the members already exists in the base. I compiled the following code in C# and examined it in reflector to see what the C# compiler does. class BaseClass { public string Bob { get { return "Bob"; } } } interface IStuff { string Bob { get; } } class SubClass : BaseClass, IStuff { } Reflector does not show any implementation in SubClass. .class private auto ansi beforefieldinit SubClass extends Enterprise.Services.OperationalActions.Business.Filters.BaseClass implements Enterprise.Services

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

北城以北 提交于 2019-11-30 14:27:50
Do you know any good book about the workings of the CLR, the .NET Framework and CIL as opposed to any specific .NET language? Regardless of any other books, you will definitely need ECMA-335 standard for a detailed specification of CLR and CIL. With sufficient experience, it may actually be sufficient on its own. Also, "Expert .NET 2.0 IL Assembler" looks like it matches your requirements, though I haven't read it and can't comment on its quality. Amazon description looks promising, though: Topics include managed executable file structure, metadata table structure, Microsoft IL instructions,

MSIL - how do you invoke a private method from MSIL?

泪湿孤枕 提交于 2019-11-30 14:13:58
I'm writing a "weak event factory" - code which converts any Delegate into a new delegate with an identical signature, but with implementing a WeakReference on the target. I'm using MSIL to avoid calls to Delegate.CreateDelegate (which performance have shown to be slow). The weak reference delegates work perfectly as long as the underlying method (the Method of the original delegate), was declared public. As soon as a private or anonymous method is used, the MSIL bombs at run time with a MethodAccessException . Using compiled expression trees, I've been able to invoke private methods, so it

Does Mono.Cecil take care of branches etc location?

半世苍凉 提交于 2019-11-30 12:43:25
Well this question may seem odd but it's simple - my point is if i have a "goto" (brtrue etc) in the decompiled code like example br IL_0003 call ***** IL_0003: ret and I add a command after that **** call will the br at the top point to ret like it should or to that code. does Cecil do it by itself or I have to take care of all those branches ? :/ it wouldn't be very hard to fix them but if Cecil doesn't then I simply won't start this project, I've no time (or knowledge) for advanced IL magic :P (yes I know it won't be IL_0003 it's just for example) Yes, Cecil will update the branch for you.

DynamicMethod is much slower than compiled IL function

流过昼夜 提交于 2019-11-30 10:52:15
问题 I wrote a simple object copier that copies public properties. I can't figure out why the Dynamic method is a lot slower than the c# version. Durations C# method : 4,963 ms Dynamic method : 19,924 ms Note that - as I run the dynamic method before starting the stopwatch - the duration do not include the compilation phase. I run that in Debug and Release mode, in x86 and x64 mode, and from VS and from the command line with roughly the same result (dynamic method is 400% slower). const int