简体   繁体   English

一个带有两个dll的Web应用程序。 一个dll依赖于另一个。 为什么必须同时更新两个DLL?

[英]One web application with two dlls. One dll is dependent upon the other. Why do I have to update both DLLs?

I have a web application that has two referenced assemblies in the form of DLLs. 我有一个Web应用程序,该应用程序具有DLL形式的两个引用程序集。 Lets call the DLLs Primary.dll and Secondary.dll. 让我们调用DLL Primary.dll和Secondary.dll。 The Secondary.dll is dependent upon Primary.dll. Secondary.dll依赖于Primary.dll。

I need to add a feature to Primary.dll for use within the web application. 我需要向Primary.dll添加功能以在Web应用程序中使用。 This requires a new version. 这需要一个新版本。 This new feature is not required by Secondary.dll. Secondary.dll不需要此新功能。 There are no breaking changes for Secondary.dll. Secondary.dll没有重大更改。

Now when a bit of code in Secondary.dll is triggered, I get the following error: 现在,当Secondary.dll中的一些代码被触发时,出现以下错误:

"Could not load file or assembly 'Primary.dll' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. " “无法加载文件或程序集'Primary.dll'或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。”

Secondary.dll is looking for the specific version of Primary.dll Secondary.dll正在寻找Primary.dll的特定版本

Is this solved simply by making the SpecificVersion="false" value in the Secondary.dll project file? 是否可以通过在Secondary.dll项目文件中设置SpecificVersion =“ false”值来解决?

If not, I've thought of keeping the older version of Primary.dll in the GAC, this way Secondary.dll would find it there. 如果没有,我曾想过将旧版本的Primary.dll保留在GAC中,这样Secondary.dll就会在其中找到它。 But would like to avoid this if possible. 但是,如果可能,请避免这种情况。

So now I'm stuck with having to rebuild and re-version Secondary.dll, with a reference to the updated Primary.dll, every time I make a change to Primary.dll for use by the web application. 因此,每次我更改要由Web应用程序使用的Primary.dll时,我都不得不重新构建和重新版本Secondary.dll,并引用更新的Primary.dll。

Is there way to make it so I don't have to update Secondary.dll's reference to the new version of Primary.dll? 有没有办法使我不必将Secondary.dll的引用更新为Primary.dll的新版本?

If changes are really not breaking, try this way: 如果更改确实没有中断,请尝试以下方式:

  1. Check assembly attributes of your Primary.dll and get rid of signing and auto-generated assembly version (change 1.0.0.* to 1.0.0.0). 检查Primary.dll的程序集属性,并删除签名和自动生成的程序集版本(将1.0.0。*更改为1.0.0.0)。
  2. If it doesn't help, open Secondary and Primary with ILSPY utility and check what the exact the reference to the Primary.dll, and compare it to the actual full assembly name of Primary.dll. 如果没有帮助,请使用ILSPY实用程序打开“辅助”和“主要”,并检查对Primary.dll的确切引用,然后将其与Primary.dll的实际完整程序集名称进行比较。 Also check references to your other dll, that could be referenced in both Primary and Secondary. 还要检查对您的其他dll的引用,这些引用可以在Primary和Secondary中引用。
  3. If it doesn't help, possible you have several files of Primary.dll assembly with different metadata and assembly loader loads the wrong one. 如果没有帮助,则可能是您的Primary.dll程序集的多个文件具有不同的元数据,并且程序集加载器加载了错误的文件。 Just find and delete wrong files or use Fusion Log Viewer utility to explore assembly binding. 只需查找和删除错误的文件,或使用Fusion Log Viewer实用程序探索程序集绑定。 Maybe, this can help . 也许这会有所帮助

To make the investigation more simple, use simple almost empty ConsoleApplication with reference to Secondary.dll to play instead of web application. 为了使调查更加简单,请使用参考Secondary.dll的几乎空的ConsoleApplication代替Web应用程序来播放。

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

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