如果我重建项目引用的 dll,是否还必须重建项目? [英] If I rebuild a dll that my project references, do I have to rebuild the project also?

查看:19
本文介绍了如果我重建项目引用的 dll,是否还必须重建项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在编写这个程序(FOO),它包含对 dll 的引用(BAR).所有 BAR 包含的是执行各种不同计算的方法.FOO 将能够在多台计算机上安装和部署.我的问题是,如果我在其中一种方法中更改公式(即将 x + y 更改为 x - y),我是否需要重建 FOO 反对新的 BAR?更重要的是,仅部署新版本的 BAR 是否安全?

I've been writing this program(FOO), and it includes a reference to a dll(BAR). All BAR contains is methods which perform various different calculations. FOO will be able to be installed and deployed on multiple computers. My question is, if I change a formula in one of the methods(i.e. change x + y to x - y), will I need to rebuild FOO against the new BAR? More importantly, is it safe to just deploy the new version of BAR?

推荐答案

@vcsjones 的评论在这里提出了一个重要的观点.

@vcsjones's comment raises an important point here.

您可以插入一个新的 DLL 作为替换当且仅当程序集版本没有改变并且您没有使用强命名程序集.

You can drop in a new DLL as a replacement if and only if the assembly version does not change and you are not using strong named assemblies.

如果版本确实发生了变化,那么您可能会收到运行时错误,因为您的程序尝试加载特定版本并获得与预期不同的版本.但是,如果没有更改方法签名,这可能会正常工作,但我不能保证它并始终建议重新编译.

If the version does change then you may receive runtime errors because your program tries to load a specific version and gets a different version than it expects. This may however work fine if no method signatures have changed but I wouldn't guarantee it and would always recommend a recompile.

这在使用强命名程序集时更成问题,因为强名称对程序集的版本和数字签名进行编码.因此,如果程序集中的任何代码发生更改,那么即使版本没有更改,数字签名也会更改,因此强名称会更改.

This is even more of a problem when using strong named assemblies since the strong name encodes both the version and a digital signature of the assembly. So if any code has changed in the assembly then the digital signature will change even if the version has not, hence the strong name changes.

这将再次导致运行时错误,因为您的程序期望的强名称与程序集强名称不匹配.所以在这种情况下总是需要重新编译.

Again this will cause runtime errors because the strong name your program expects will not match the assembly strong name. So in this case a recompile is always required.

总结:

  • 代码更改、无版本更改且无强名称 - OKs
  • 版本更改和无强名称 - 可能需要重新编译,推荐
  • 代码更改和强命名 - 需要重新编译
  • 版本更改和强命名 - 需要重新编译

这篇关于如果我重建项目引用的 dll,是否还必须重建项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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