Fixing Bugs in 3rd Party .NET Assemblies

June 29, 2015

Blog | Technology | Fixing Bugs in 3rd Party .NET Assemblies
Fixing Bugs in 3rd Party .NET Assemblies

Discovering old bugs in inherited codebases is a fact of life in software development. Developers read the bug ticket, track down the error, fix the code, test the fix, and release it.

But… what if the project source code has been misplaced and the previous vendor has gone out of business? Unfortunately, it can happen.

Imagine working on a large enterprise application (for which source was available) with an obscure race condition in a library (where the source had been lost to the winds of time).

In theory, the dependency on the library for this use case could have simply been replaced, but if the business logic was extensive and poorly documented, it would likely take an enormous amount of time to re-implement. For fun, let’s maintain that with the exception of the race condition, the library did everything it was supposed to do without issue.

With the use of Telerik’s JustDecompile and the Reflexil plugin, developers can go in and actually fix the issue directly in the assembly.

Let’s look at how we can accomplish this with a minimalist example.

Sample consumer:

namespace SampleConsumer
    class Program
        static void Main(string[] args)
            var foo = new FooProvider();
            var result = foo.Multiply(3, 3);
            Console.WriteLine("The provider says the result is: {0}", result);

Sample provider with a bug in it:

namespace SampleVendorLibrary
    public class FooProvider

        public int Multiply(int i, int j)
            return i*2;


Results of running the application:

Now, let’s pretend we don’t have the source to the vendor library. How do we fix the issue? Here’s where JustDecompile and Reflexil come in.

The offending assembly, opened in JustDecompile:

Load the Reflexil plugin:

Right click the offending code, click edit, and fix the bug!

But wait, what’s that you say? You’re not fluent in MSIL? Don’t worry, there are options for you too! Simply choose the ‘Replace All With Code’ option instead, and you can make your edits directly in C#.

Let’s put it to the test. Push the ‘Compile’ button to compile the C# code to MSIL:

Hit ‘OK’ to accept the results, then right click the assembly name, go the reflexil menu item, and save the assembly.

Did it work? Let’s find out…


While this isn’t a technique you’re likely to need often, but when you do, it can be a real lifesaver.

Jay Oliver, Chief Technology Officer, GeekHive

Jay Oliver

Chief Technology Officer
  • .NET

Recent Work

Check out what else we've been working on