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
?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- Why does const allow implicit conversion of refere
Concerning the case where the referenced assembly is strongly named: Suppose A is any assembly, B is a strongly-named assembly, and A references B. Then (in contrast to claims made above?) it is possible to change the contents of B without recompiling A. I just tried this, with a trivial console application for A and a class library for B. Changes to the strongly-named B caused no runtime error in A. There is a special case, however: If B makes the transition from not-strongly-named to strongly-named, then A needs to be recompiled, otherwise the will be runtime errors.
Nope - you can drop in a new DLL as needed. As long as the new DLL doesn't break any old functionality, there is no need to rebuild the referencing project.
@vcsjones's comment raises an important point here.
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.
To summarize:
If you change a formula contained in a method, there is no need to rebuild the program. However if you modify the signature of a method by changing the calling arguments it will be necessary to rebuild the program.
You just have to make sure the dll for the
Bar
project is in the bin for theFoo
project. As long as the method signatures haven't changed you're good.