How to replace a class in a dll?

c#, dll

Solution

If you are using .NET 4.0. or higher, take a look at the: MethodRental.SwapMethodBody Method

Other way: CLR Injection: Runtime Method Replacer

Problem

The subject is pretty vague since I'm not sure what's the correct terminology for what I'm trying to do. I've downloaded a `dll` (I don't have the source code), and using a reflection tool, I found a bug in the `dll` implementation. The bug is easy to fix. So let's say the bug is here: ``` class A { void f() { // BUG!!! } } ``` Is there any way to implement my own `A` which would fix the bug and inject it in runtime to replace other `A` instances?

Original source

Related problems