Skip to main content

You can debug DynamicMethod'sDynamicMethod's using the EventPipeEventPipe API. I've written a library that uses it to allow for code injection via DynamicMethodDynamicMethod that can be debugged: https://github.com/damieng/DamienG.Library/blob/master/DamienG.Library/Diagnostics/EventPipe/DynamicMethodInjector.cs

First, create a new DynamicMethodInjector object: var injector = new DynamicMethodInjector("MyTypeName", "MyMethodName");  

Then, add some IL to your DynamicMethodDynamicMethod: injector.AddMethodBody(ILGenerator il);  

You can then invoke the DynamicMethodDynamicMethod as normal, adding a breakpoint to the EventPipe.Start method to avoid hitting the breakpoint before the IL is injected:   // Inject IL into the process injector.Inject();

// Invoke your DynamicMethod var result = (int)m.Invoke(obj, new object[] { 1, 2 });

You can debug DynamicMethod's using the EventPipe API. I've written a library that uses it to allow for code injection via DynamicMethod that can be debugged: https://github.com/damieng/DamienG.Library/blob/master/DamienG.Library/Diagnostics/EventPipe/DynamicMethodInjector.cs

First, create a new DynamicMethodInjector object: var injector = new DynamicMethodInjector("MyTypeName", "MyMethodName");  

Then, add some IL to your DynamicMethod: injector.AddMethodBody(ILGenerator il);  

You can then invoke the DynamicMethod as normal, adding a breakpoint to the EventPipe.Start method to avoid hitting the breakpoint before the IL is injected: // Inject IL into the process injector.Inject();

// Invoke your DynamicMethod var result = (int)m.Invoke(obj, new object[] { 1, 2 });

You can debug DynamicMethod's using the EventPipe API. I've written a library that uses it to allow for code injection via DynamicMethod that can be debugged: https://github.com/damieng/DamienG.Library/blob/master/DamienG.Library/Diagnostics/EventPipe/DynamicMethodInjector.cs

First, create a new DynamicMethodInjector object: var injector = new DynamicMethodInjector("MyTypeName", "MyMethodName");

Then, add some IL to your DynamicMethod: injector.AddMethodBody(ILGenerator il);

You can then invoke the DynamicMethod as normal, adding a breakpoint to the EventPipe.Start method to avoid hitting the breakpoint before the IL is injected:   // Inject IL into the process injector.Inject();

// Invoke your DynamicMethod var result = (int)m.Invoke(obj, new object[] { 1, 2 });

Source Link

You can debug DynamicMethod's using the EventPipe API. I've written a library that uses it to allow for code injection via DynamicMethod that can be debugged: https://github.com/damieng/DamienG.Library/blob/master/DamienG.Library/Diagnostics/EventPipe/DynamicMethodInjector.cs

First, create a new DynamicMethodInjector object: var injector = new DynamicMethodInjector("MyTypeName", "MyMethodName");

Then, add some IL to your DynamicMethod: injector.AddMethodBody(ILGenerator il);

You can then invoke the DynamicMethod as normal, adding a breakpoint to the EventPipe.Start method to avoid hitting the breakpoint before the IL is injected: // Inject IL into the process injector.Inject();

// Invoke your DynamicMethod var result = (int)m.Invoke(obj, new object[] { 1, 2 });