Hi,
First of all, this line won't work:
String.Format("Unhandled AppDomain exception", args);
You need to have {0} somewhere in your string, which will be replaced by
args.ToString(). That's what String.Format() does. I'm not sure that this
will cause a runtime exception, or will just have your extra parameter
ignored, but still figured you should know.
Now, on to your actual problem. The ldarg instruction loads a method
argument. ldarg.2 is a shorthand-form for this, it's used to keep the code
size small.
My advice would be for you to use the MethodBody.ExpandMacros() extension
method is Mono.Rocks.dll when you begin working with a method, and
MethodBody.SimplifyMacros() when you're done working with it.
ExpandMacros() will turn ldarg.2 (which doesn't have an operand, because
it's a short form) to ldarg <ParameterReference>, which will now have an
operand of type ParameterReference. That'll give you all the information you
need.
SimplyMacros() will optimize the instructions again, and will use
shorthand-forms whenever possible.
Hope this helps!
2011/7/5 rumpa.maji <[email protected]>
> Hello All,
>
> I am facing a problem while using Mono.Cecil.
> I have the below code in my program,
> private void CurrentDomainUnhandledException(object sender,
> UnhandledExceptionEventArgs args)
> {
> String.Format("Unhandled AppDomain exception", args);
> }
> I am facing a problem in reading the type of args using Mono.Cecil
> It is giving me information about "Unhandled AppDomain exception" argument
> and its type as string and the Operand is also not null, but for the second
> argument "args", it is showing it as ldloc or ldarg.2 and
> instruction.Operand is showing as null. I want to retrieve the Operand for
> "args".
>
> My requirement is , i want to read the type of the "args" argument, in this
> example, it is "UnhandledExceptionEventArgs".
>
> Please help me.
> Thanx in Advance.
>
> Regards
> Rumpa Maji
>
>
>
> --
> View this message in context:
> http://mono.1490590.n4.nabble.com/Reading-the-type-the-second-argument-passed-to-String-Format-string-s-object-obj-method-using-Mono-cl-tp3645549p3645549.html
> Sent from the Mono - Cecil mailing list archive at Nabble.com.
>
> --
> --
> mono-cecil
--
--
mono-cecil