开发者

If I add a public method to a C# class, do I need to recompile other assemblies using that type?

Question in the title.

I'd like to avoid recompiling since the source code I'm modifying is third party and I'd like to开发者_如何学JAVA use the original binaries where possible, and replace only the assembly which contains the class I modified. But I'm not sure if this is a safe thing to do. In C++ for example this is definitely a bad idea.


No.

The assemblies that reference your library refer to methods and types using (some form of) name, so as long as you don't change the names of public types and methods (used by other assemblies), you don't need to recompile any of the assemblies - they will work with the updated version of the library.


In most cases Tomas answer is correct, but there are some cases where it is not true:

  1. When using strong naming (signing) change of a single character leads to a new signature, thous leading to a new strong name.
  2. Setting in your project references for your assembly the property Specific Version to true and changing the version number manually or automatically in AssemblyInfo.cs


No. All other assemblies will automatically work with the newly updated library.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜