On 23/12/2011 11:44, seesharper wrote:
Hi!

I have this case where I need to inject code in a constructor AFTER
the call to the base constructor.

This is modifying an existing type so I do not have control over
calling the base constructor.

Is there any way I can search through the instructions and detect the
call to the base constructor.

    L_0000: ldarg.0
    L_0001: call instance void [mscorlib]System.Object::.ctor()
  ->  Inject code here ........

Is there any generic way I can solve this so I can make sure my code
is injected after the call to the base constructor?


Look for a *call* to a .ctor, there should be only 1. (new is used to instantiate while call is only used for base/this calls)


--
Carlo Kok
RemObjects Software

--
--
mono-cecil

Reply via email to