Helping you solve those tough coding problems!

Two different versions of the same DLL with C# Two different versions of the same DLL with C#

Published on Apr 13, 2019 by Jamie Munro

Recently I was stuck with the error Try removing one of the references or sign them to enable side-by-side. This is not a common error, but I received it because I was in the very unfortunate situation of requiring to have two different versions of the same DLL installed in my solution. Let's explore how I worked around this.




Here is some background of what I was trying to accomplish. I had an existing API integration with Stripe.net. This integration was very old, as in 5 years old. The integration was working flawlessly so we never upgraded the SDK we were using.

Recently Stripe has introduced Stripe Connect where, using OAuth, the client agrees to you, the provider, to perform API and direct charge requests. The old way was to simply use the client's API keys. This is now discouraged.

Of course the version of the SDK we were using doesn't support this newer Stripe Connect functionality.

My first thought was that I could install different versions of the Stripe NuGet package by creating different projects. This allowed me to compile my code. However, when I ran it I received the dreaded run-time error regarding side-by-side references.

It was a given that we had to support both integrations while we migrate our existing clients to the new Stripe Connect approach.

Let's continue on to the solution.

Try removing one of the references or sign them to enable side-by-side



Two different projects I think is still a good solution, so how to solve the duplicate references. My solution was as follows:


  1. Download the source code for Stripe's SDK for the old version I was using.

  2. With the old version downloaded, I opened the solution and changed the AssemblyTitle and the actual name of the .NET project.

  3. I changed both of these values to Stripe.old.

  4. I compiled the source code (in Release mode).

  5. I removed the old version of the NuGet package.

  6. In my existing project I manually included a reference to my newly compiled DLL with the name of Stripe.old.

  7. I left the latest version of the Stripe.net NuGet package in my new project.

  8. Recompiled and no more run-time error.



This allowed me to overcome the Try removing one of the references or sign them to enable side-by-side error.

In my BIN directory I now have two Stripe DLLs: Stripe.old.dll and Stripe.net.dll. This is the secret to have two different versions of the same library in your C# projects. Perhaps not the prettiest solution, but it allowed me to support both implementations without having to refactor the original implementation.

Tags: dll | ASP.NET | c#

My Books
ASP.NET MVC 5 With Bootstrap and Knockout.js
Knockout.js Building Dynamic Client-Side Applications
20 Recipes for Programming MVC 3
20 Recipes for Programming PhoneGap
Rapid Application Development with CakePHP