在程序中加载依赖项(dll的不同版本)的常见做法 [英] Common practice to load the dependency(different version of dll) in program

查看:70
本文介绍了在程序中加载依赖项(dll的不同版本)的常见做法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设有一个使用2个第三方dll的代码.一个是用于登录的 NLog.Extensions.Logging 版本 1.6.1 ,另一个是用.net标准2.0编写的 CryptoProvider.dll .内部使用 Microsoft.Extensions.Logging 版本 2.1.0 内部 NLog.Extensions.Logging ,而内部使用 CryptoProvider.dll Microsoft.Extensions.Logging 版本 2.0.0 .因此,现在存在有关版本不匹配的问题.所以我应该如何设计CryptoProvider dll.以便解决问题.

Suppose there is a code which use 2 third party dll's. one is NLog.Extensions.Logging version 1.6.1 for logging other is lets say CryptoProvider.dll written in .net standard 2.0. NLog.Extensions.Logging internally using Microsoft.Extensions.Logging version 2.1.0 while CryptoProvider.dll internally use Microsoft.Extensions.Logging version 2.0.0. So now there is a issue regarding version mismatch. So how should I design to CryptoProvider dll. so that resolve the issue .

推荐答案

可以使用 app.config 文件

这可以将所有程序集Newtonsoft.Json版本引用重定向到 12.0.0.0 .通常,如果安装的软件包具有不同的依赖版本,则VS会自动添加这些重定向.

This can redirect all assembly Newtonsoft.Json version references to be resolved to 12.0.0.0. Usually VS adds those redirects automatically if installed packages has different dependency versions.

但是,只有在重定向版本之间没有重大更改时,它才有效.

But it works only if there are no breaking changes between the redirected version.

不确定在.net framewok和.net核心程序集之间混合使用是否可行.

Not sure that it will work to mix between .net framewok and .net core assemblies.

.net核心的组装绑定重定向可以是使用 deps.json

这篇关于在程序中加载依赖项(dll的不同版本)的常见做法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆