I have a solution with multiple projects. There is a need that I have to refer to a different version of the same assembly in two different projects.
When building the projects, one DLL is overwriting the other DLL, because they are both being compiled in the same folder. So the DLL that depends on the older version fails with an error.
Could not load file or assembly XXXX or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.
In my research, I have found that we can load DLL from a different location using the tag in the app config file of the project.
Approach 1: In Project B, I have added the following line of code in the "app.config" file.
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="SampleExample"
publicKeyToken="XXXXXXXXXXXXXX"
culture="neutral" />
<codeBase version="2.0.8.0"
href="FILE://C:/Users/username/source/repos/Solution/Project A/bin/Debug/DLL/SampleExample.dll"/>
</dependentAssembly>
</assemblyBinding>
Using the above approach I am still facing the same error and the project is not able to load DLL with the desired version.
Approach 2: In Project A, I have added the following line of code in the "app.config" file.
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="SampleExample"
publicKeyToken="XXXXXXXXXXXXXX"
culture="neutral" />
<codeBase version="2.0.8.0"
href="FILE://C:/Users/username/source/repos/Solution/Project A/bin/Debug/DLL/SampleExample.dll"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
Here in Project A, when performing the above changes I am able to execute the project successfully without any error.
I want to know, is there any way we can use Approach 1 and the application works correctly? I also want to know updating the same line of code in the Project A application was working correctly without any error so will that affect Project C as I am not sure Approach 2 will have any impact on Project C behavior or functionality?
Here Is there any other approach we can use to resolve the issue, where we can use the same DLL with a different version in Project B and Project C?