.NETGURU
binary compatibility support for .NET assembly
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.sdk.

Post a new message to this list...

someone
Suppose that I have a class in an assembly that is delivered to the user,
what can I do to change the class so that it doesn't break the
binary compatibility? That is, user application can run with recompiling
and relinking.

I know that if I define an interface, and only expose the interface but not
the class which implments the interface, I can add a data member to the
class without breaking the binary compatibility. If the class itself,
rather than the interface is exposed to user, can I still add a data member
to the class without breaking the binary compatibility? What are other
restrictions that won't break the binary compatibility?

In pure C++, adding a data member to a class that is exposed to the user
will break compatibility.

Thanks.

Reply to this message...
 
    
someone
[Original message clipped]

A mistake: 'with' should be 'without'.

Reply to this message...
 
    
Niki Estner
"someone" <Click here to reveal e-mail address> wrote in
news:%Click here to reveal e-mail address...
[Original message clipped]

..net applications are just-in-time compiled; There is no "linker". The kind
of tasks that used to be done by the linker are done at runtime (by the JIT)
anyway.

> I know that if I define an interface, and only expose the interface but
not
[Original message clipped]

Yes.

> What are other restrictions that won't break the binary compatibility?

Don't remove methods, make them private or change their signature if they
are used by the client. You'll get a "MissingMethodException" if the JIT
can't find a method that's called in your code.

[Original message clipped]

Yep. There are ways around this, but they usually require some work.
That's one of the reasons why .net was invented.

Niki

Reply to this message...
 
    
Niki Estner
"Niki Estner" <Click here to reveal e-mail address> wrote in
news:ez9YT%Click here to reveal e-mail address...
[Original message clipped]

Sorry, that wasn't 100% correct: There is a linker (al.exe) that fuses
modules and resources, but it is rarely used, at least not in a usual
VS-build cycle.

Niki

Reply to this message...
 
    
someone
What about enumeration constants defined? if their value is changed, I
assume that the binary compatibility is broken. I know that this is true in
C++.

"Niki Estner" <Click here to reveal e-mail address> wrote in message
news:ez9YT%Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Niki Estner
I'm sorry, my first reply was definitely too short; Unfortunately I didn't
find any good article on the subject; So, here's a short list of things I
that came to my mind right now; In general
- You may safely change default values of data members
- You may safely change all private/internal fields of a class/struct
- You may usually add properties or methods to an existing class or struct
(this only hurts the client if it derives a class from that class, and
happens to add a property/method with the same signature)
- You may usually add data members and events to a class or struct, unless
you use binary serialization in your clients (the binary layout changes with
new data members)
- Removing, renaming or changing the type/signature of public/protected
properties/data members/events/methods can cause clients to crash (however
unlike C++ you'll get something like a "MethodNotFoundException", and no
memory will be overwritten) if (and only if) the client uses that member
- Removing an interface or changing the base class may hurt clients, if the
client casts to that class/interface
- Changing static constants/enums causes clients to break (didn't think of
that before your post)

Of course this list isn't complete, and there are may still be some cases
where even these rules don't work (e.g. if the client tries to invoke a
non-existing method using late-binding; If you add that method, the client
will behave differently). But I hope that this at least gives you a rough
sketch of what is done at compile-time, and what is done at run-time.

In general, if you expect an assembly to change often, using interfaces for
communication is not a bad idea.

Niki

"someone" <Click here to reveal e-mail address> wrote in
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
 
System.MissingMethodException




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification