There are two same .dll but different version in different folder. How can I force the program to refer the version I want?

Daniel_ngai 1 Reputation point

I am making a plugin for a application. I installed latest version of AWS.S3 (Amazon Cloud) from NuGet. It successfully includes in the \bin\AWSSDK.S3.dll.

However, the application already has a same .dll file in the its root folder (C:\Program Files\Application\AWSSDK.S3.dll) which is in older version.
And the program shows error as my code have to run in newer version. How can I force my plugin to load the dll from assembly folder instead of root folder?

Thanks a lot

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.
10,601 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Daniel Zhang-MSFT 9,621 Reputation points

    Hi Danielngai-6932,
    You can add a probing path to your application's .config file, and it will only work if the probing path is a contained within your application's base directory.

            <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">  
                <probing privatePath="bin;bin2\subbin;bin3"/>  

    You can also use the AppDomain.AssemblyResolve event and manually load the dependencies from your DLL directory.
    More details you can refer to the following threads.
    How to add folder to assembly search path at runtime in .NET?
    c# Class Library Project - Load DLL from same folder?
    Best Regards,
    Daniel Zhang

    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments