How to use multiple DLLs with the same name

Corey Fleig 160 Reputation points
2025-12-09T01:14:42.65+00:00

Years ago I built web apps on my local box, and copied the ASP.NET files over to our web server. This included creating a bin directory, and placing the needed DLLs there. Everything runs great.

Now, years later, I'd like to add a new app, and use much newer 3rd party DLLs with the same name. However, these newer DLLs are not backwards-compatible. I can't overwrite the original DLLs in the bin directory, and I tried using <probing> but that didn't accomplish what I need.

Is there a way, for example, for app1 to use bin\some.DLL, and app2 to use some_other_dir\some.DLL, but not look to load from bin first?

Developer technologies | C#
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Q&A Assist
    2025-12-09T01:14:50.5333333+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    To use multiple DLLs with the same name in different applications without causing conflicts, you can consider the following approaches:

    1. Separate Application Pools: If you're hosting your applications on IIS, you can configure each application to run in its own application pool. This way, each application can have its own set of assemblies, and they won't interfere with one another.
    2. Use Different Directories: Place the newer version of the DLL in a separate directory specific to the application that requires it. You can then modify the application's configuration file (e.g., web.config) to include a <probing> element that points to the specific directory where the newer DLL is located. However, as you mentioned that probing did not work for you, ensure that the path is correctly specified and that the application is configured to look in that directory first.
    3. Assembly Binding Redirects: If you have control over the applications, you can use assembly binding redirects in the web.config file. This allows you to specify which version of the DLL to load at runtime, but this may not work if the newer DLL is not backwards-compatible.
    4. Shadow Copying: Enable shadow copying for your applications. This allows the application to load assemblies from a temporary location rather than the bin directory, which can help avoid conflicts.
    5. Use Strong Naming: If you have the ability to modify the newer DLLs, consider strong naming them. This creates a unique identity for the assembly, allowing you to have multiple versions of the same DLL in the GAC (Global Assembly Cache) or in different directories without conflict.

    By implementing one or a combination of these strategies, you should be able to run multiple applications that require different versions of the same DLL without issues.

    0 comments No comments

  2. Susmitha T (INFOSYS LIMITED) 1,640 Reputation points Microsoft External Staff
    2025-12-09T09:33:11.73+00:00

    Thank you for reaching out!

    If you want two web apps to use two different DLLs with the same name, deploy them as two separates ASP.NET applications, each with its own /bin folder. ASP.NET loads DLLs per application: each app gets its own assembly cache and does not mix DLLs even if the names are identical.

    In other words, Put some.dll (old version) in App1/bin, and some.dll (new version) in App2/bin. The apps will remain isolated and use their respective DLL versions.

     

    Put Each App in its Own Application Directory:

    If you have:

    /App

        /bin

            some.dll (old version)

    /App2

          /bin

             some.dll (new version)

     

    ASP.NET will not mix these DLLs.

    Each App loads only the DLLs inside its own /bin directory.

     

    This requires:

    • App1 and App2 must be separate virtual apps in IIS (Not subfolders of the same app unless marked as apps)
    • Each app must have its own web.config and bin folder

     

    What will not work:

    • Putting both DLLs in the same /bin folder
    • Using <Probing> to force different versions
    • Using shadow copying tricks

     

    ASP.NET will always load from its own /bin before probing any additional paths, So you cannot override that inside one application.

     

    Reference: https://learn.microsoft.com/en-us/previous-versions/aspnet/ff651860(v=orm.10)

     

     

     Let me know if you need any further help with this. I will be happy to assist. If you find this helpful, Kindly mark the provided solution as "Accept Answer", so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.


  3. Bruce (SqlWork.com) 81,981 Reputation points Volunteer Moderator
    2025-12-09T18:02:10.93+00:00

    Typically you would rename one of the dlls and use an alias statement to change the namespace. This won’t work if the dll calls other duplicate dll’s.

    If this is .net 4.* the you can but the the dll’s in their own folder and create an isolated app domain and load the dll’s into this app domain and use cross domain calls.

    https://learn.microsoft.com/en-us/dotnet/framework/app-domains/use

    a better approach is to just update the code to use the versions.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.