简体   繁体   English

C#.Net Dll引用依赖项

[英]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.

相关问题 .Net Scripting Engine (C#) - .Net 语言是否有某种“头文件”或“dll 引用文件”? - .Net Scripting Engine (C#) - Is there some sort of “header file” or “dll references file” for .Net languages? 添加两个DLL的引用C# - adding both dll's references c# C#dll引用产生classnotfound异常 - C# dll references produce a classnotfound exception C# .net 4 依赖项 - C# .net 4 dependency VB.NET Windows窗体应用程序引用可以在引用C ++ DLL的C#DLL中调用函数吗? - Can a VB.NET windows forms app reference and call a function in a C# DLL that references a C++ DLL? 如何从.net C#exe或dll获取引用和导入模块的列表? - how can a list of references and imported modules be obtained from a .net C# exe or dll? 混合使用.Net Standard 和.Net Framework 时,如何自动部署隐藏的NuGet 依赖项的C# DLL? - How to deploy C# DLL of hidden NuGet dependency automatically when mixing .Net Standard and .Net Framework? 引用其他项目dll的C#cmdlet dll加载失败 - C# cmdlet dll that references other project dll fails on load C# 如何将 DLL 中的引用与 DLL 一起加载? - C# How do I load the references in the DLL together with the DLL? 在C#DLL中运行时动态解析依赖关系 - Dynamically Resolve Dependency at Runtime in C# DLL
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM