I have created 3 projects:
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:
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
}
static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
if (args.Name == "LiteDB, Version=1.1.1.0, Culture=neutral, PublicKeyToken=null")
{
return Assembly.LoadFrom(@"..\..\..\packages\LiteDB.1.1.1\lib\net\LiteDB.dll");
}
// The most recent version will be copied to the output directory.
// Use the normal resolution mechanism to locate it.
return null;
}