我已经创建了3个项目:
V_1_OperationProject包含从LiteDB v1 dll和类似于V_4_OperationProject创建的DB文件中打开和嵌入的逻辑。
当我要从V_1_OperationProject插入DB中的值时,我会得到以下异常:
System.IO.FileLoadException:“无法加载文件或程序集”LiteDB、Version=1.0.0.0、Culture=neutral、PublicKeyToken=null“或其依赖项之一。所定位的程序集的清单定义与程序集引用不匹配。(HRESULT例外: 0x80131040)‘
当我删除了V_4_OperationProject及其相关的DLL后,它就开始工作了。但我想两个人都工作。
因此,我尝试在主要项目中添加以下内容:
<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>这也不适合我。有人能帮我吗??提前谢谢
发布于 2018-11-23 13:25:44
您需要告诉运行时在哪里查找每个版本。您可以使用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;
}发布于 2018-11-27 15:01:28
这两个LiteDB版本将有单独的代码和数据。但是,它们可能还有其他冲突的方式,比如共享公共配置、端口号或其他什么。我想你得试试看它是否适合你。
https://stackoverflow.com/questions/53447256
复制相似问题