[英]C# .Net Dll References Dependency
I have written a DLL library MyLIB.dll (version 1.0.0 ) that depends on the third party DLL library OtherLIB.dll (version 1.0.0 ). 我编写了一个DLL库MyLIB.dll (版本1.0.0 ),它依赖于第三方DLL库OtherLIB.dll (版本1.0.0 )。 Library OtherLIB.dll is available on the NuGet and I'm adding it to the MyLIB.dll project via NuGet package manager.
库中的OtherLIB.dll在NuGet上可用,我通过NuGet包管理器将它添加到MyLIB.dll项目中。
Now let's say that I'm writing a new application, say MyAspNetMvcApp and I'm adding MyLIB.dll (version 1.0.0 ) to it via NuGet. 现在让我们说我正在编写一个新应用程序,比如MyAspNetMvcApp ,我正在通过NuGet向它添加MyLIB.dll (版本1.0.0 )。 It automatically adds OtherLIB.dll (version 1.0.0 ) as it depends on it.
它会自动添加OtherLIB.dll (版本1.0.0 ),因为它依赖于它。 Everything is working fine, but...
一切都很好,但......
After a month there is being released a new version of OtherLIB.dll - version 1.0.1 . 一个月后,发布了新版本的OtherLIB.dll - 版本1.0.1 。 I'm updating it via NuGet.
我正在通过NuGet更新它。
Now, My ASP.NET MVC application stops working because there is being thrown an exception by MyLIB.dll . 现在,我的ASP.NET MVC应用程序停止工作,因为MyLIB.dll引发了异常。 It expects OtherLIB.dll in version 1.0.0 but there is already newer version being used.
它期望版本1.0.0中的 OtherLIB.dll ,但已经使用了更新的版本。
In MyLIB.dll project references I can see that "Specific Version" flag for OtherLIB.dll is being set to "False", so I have no idea what's going on here... 在中是指mylib.dll项目引用我可以看到,对于OtherLIB.dll“特定版本”标志被设置为“假”,所以我不知道是怎么回事......
Is there any possibility to solve this issue in other way than by providing assembly binding in web.config file? 除了在web.config文件中提供程序集绑定之外,是否有可能以其他方式解决此问题? How can I add a reference to OtherLIB.dll for MyLIB.dll in such way that there will be no exception when I update OtherLIB.dll to a newer version?
如何为MyLIB.dll添加对OtherLIB.dll的引用,以便在将OtherLIB.dll更新为较新版本时不会出现异常?
I ran into this yesterday for visual studio web developer using Oracle.DataAccess.dll. 我昨天遇到了使用Oracle.DataAccess.dll的visual studio web开发人员。
My solution, 我的解决方案
right click your project solution (*.csproj) and edit it. 右键单击您的项目解决方案(* .csproj)并进行编辑。
Right underneath: 正下方:
<PropertyGroup>
Place 地点
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
Then rebuild your solution. 然后重建您的解决方案。 You must separate the two version dlls into two different directories in your project when including them (required).
在包含它们时,必须将两个版本dll分成项目中的两个不同目录(必需)。
I did 我做到了
ora11 >> Oracle.DataAccess.dll (Version 11)
ora11 >> Oracle.DataAccess.dll(版本11)
ora9 >> Oracle.DataAccess.dll (Version 9)
ora9 >> Oracle.DataAccess.dll(版本9)
Doing this allows your IDE to use both versions of DLLs. 这样做允许IDE使用两个版本的DLL。
It's possible that your MyLIB.dll
is set to use a specific version of OtherLIB.dll
. 您的
MyLIB.dll
可能设置为使用特定版本的OtherLIB.dll
。 Go into your MyLIB
project and click on the reference to OtherLIB.dll
. 进入
MyLIB
项目并单击对OtherLIB.dll
的引用。 Check the properties to see if "Specific version" is set to true. 检查属性以查看“特定版本”是否设置为true。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.