Maintaining backwards compatibility

C

cpnet

I'm designing a solution that will involve a few assemblies, and one or two
of these assemblies (that the other assemblies will need to reference) will
change frequently. I think I understand how to handle setting the version
numbers and publisher policy files to make sure that my 'old' assemblies can
use the new backwards-compatible assemblies. But, obviously when I update
the assemblies that will change frequently, I can't change just anything in
the code. What are the restrictions? My assumption would be that I
couldn't alter the name and signature of public or protected methods of
public classes. Can I add new public/protected methods to public classes
though (probably not)? I assume I can do whatever I want with private or
internal classes, methods or properties right? Are there any restrictions
on changes I may make to attributes in my code?

Thanks
 
K

Kevin Yu [MSFT]

Hi cpnet,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to keep assemblies
backwards-compatible when reference by other assemblies. If there is any
misunderstanding, please feel free to let me know.

When upgrading the assembly, we have to keep the old interfaces unchanged,
which means you can change the implementation, but you cannot change the
method name, arguments and return types of protected and public methods.
However, you can add new methods.

When assembly A references assembly B, A will first look for the
corresponding version and culture and then public key. When no version is
match, it will look for the latest version with the same assembly name and
same public key.

HTH

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
C

cpnet

I think you understood my question. I basically wanted to know if I could
add new public/protected methods/properties to public classes, and if I
could add private/internal methods/properties to public classes while
remaining backwards compatible. From your answer, it seems I can do both
(which is good - although I am a little suprised that I can add new
public/protected methods to public classes).

Thanks,
cpnet
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top