I need to use a bit older version of this assembly.
That is not what assembly redirects are for. The purpose of assembly binding redirects is so you can use a newer version of an assembly that is a dependency of an assembly that was compiled against an older version.
For example, your application depends on LibraryX
and LibraryX
depends on LibraryY
version 1.0.
YourApp -> LibraryX (v3.2) -> LibraryY (v1.0)
For the sake of argument, your application needs to use version 2.0 of LibraryY
directly.
YourApp -> LibraryX (v3.2) -> LibraryY (v1.0)
-> LibraryY (v2.0)
This won't work because your application is using a newer version of LibraryY
than LibraryX
was when it was compiled.
So, we add a binding redirect to force LibraryX
to use the same version as YourApp
.
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="LibraryY" publicKeyToken="89b483f429c4fecd"/>
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Which changes it to:
YourApp -> LibraryX (v3.2) -> LibraryY (v2.0)
-> LibraryY (v2.0)
Your Case
If you want to use an older version of the assembly in your application, then you need to reference the older version in your application. This problem cannot be solved using binding redirects, only by using a direct assembly reference to the specific version of Oracle.DataAccess
your application needs to use.
In your application's .csproj
file:
<ItemGroup>
<Reference Include="Oracle.DataAccess, Version=2.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86">
<SpecificVersion>True</SpecificVersion>
<HintPath>C:\Windows\assembly\GAC_32\Oracle.DataAccess\2.121.1.0__89b483f429c47342\Oracle.DataAccess.dll</HintPath>
</Reference>
<ItemGroup>
Note that I am not sure about whether Oracle.DataAccess
is an x86 or x64 GAC reference, so if the latter you may need to change both the processorArchitecture
and HintPath
above to match.
Reference: Redirecting Assembly Versions