I have created 3 projects:
- V_1_OperationProject:
(Class library project)To handle operation on LiteDb version 1 - V_4_OperationProject :
(Class library project)To handle operation on LiteDb version 4 - MainProject:
Gives the calls to methods in V_1_OperationProject and V_4_OperationProject project
V_1_OperationProject contains logic to open and inset into DB file created from LiteDB v1 dll and similarly with V_4_OperationProject.
When I am going to insert values in DB from V_1_OperationProject, I am getting following exception:
System.IO.FileLoadException: 'Could not load file or assembly 'LiteDB, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)'
When I have removed V_4_OperationProject and its associated DLL then it got started working. But I want both to work.
So I have tried adding following in main project:
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="LiteDB"
publicKeyToken="4ee40123013c9f27"
culture="neutral" />
<bindingRedirect oldVersion="0.0.0-1.0.0" newVersion="1.0.0" />
<bindingRedirect oldVersion="1.0.1-4.0.0" newVersion="4.0.0" />
<codeBase version="1.0.0" href="\LiteDB-1\LiteDB.dll" />
<codeBase version="4.0.0" href="\LiteDB-4\LiteDB.dll" />
</dependentAssembly>
</assemblyBinding>
This is also not working for me. Can anyone please help me in this?? Thanks in Advance
You need to tell the runtime where to look for each version. You can do so using AssemblyResolve: