简体   繁体   English

在一个应用程序中使用不同版本的dll文件

[英]Use different versions of dll file in one app

I have an c# application with two libraries ( moon-apns, tweetsharp ) .. Each library has a reference for newtonsoft.json.dll but different versions ... My app build successfully but one library works fine and the other one throws an exception ( can't find the dll file ). 我有一个带有两个库的c#应用程序(moon-apns,tweetsharp)..每个库都有对newtonsoft.json.dll的引用但不同的版本...我的应用程序构建成功但是一个库工作正常而另一个库引发异常(找不到dll文件)。

I think that when i build only one version goes to the bin folder, but i don't know what to do. 我认为当我构建只有一个版本进入bin文件夹,但我不知道该怎么做。

Thanks in advance. 提前致谢。

You can force both libraries to reference the same version by using Assembly Binding Redirects in your app.config or web.config. 您可以通过在app.config或web.config中使用程序集绑定重定向来强制两个库引用相同的版本。 Obviously this only works as long as the library versions are compatible. 显然,只有库版本兼容,这才有效。

Since you stated you have access to the source of the two libraries: 既然您声明可以访问两个库的源代码:

In both projects, set the reference to newtonsoft to not required Specific Version . 在这两个项目中,将对newtonsoft的引用设置为不需要的Specific Version Rebuild those projects. 重建这些项目。

Now, when you build your main project, the two libraries should be ok with the same version of the newtonsoft DLL as long as there is no compatibility issues 现在,当您构建主项目时,只要没有兼容性问题,两个库就可以使用相同版本的newtonsoft DLL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM