473,385 Members | 1,555 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

binary compatibility support for .NET assembly

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.
Nov 22 '05 #1
6 3239
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.


A mistake: 'with' should be 'without'.
Nov 22 '05 #2
hi
when you are speaking about com and binary
compatibility.Adding an interface only generates a new iid
and does not break the binary compatibility as new version
can use the new features(class with new iid included)
where as the older version still works with their older
version.The compatibility breaks only when you changes the
signatures or remove some interfaces etc.
But with .Net you need not to depend on registry .The only
thing you remember is how are you handling the versioning
and whether you are using private or shared
assemblies.Therefore you need not have to be worried about
binary compatibility at all because in .net multiple
version can run side by side and even you can specify
which client or application will use which version of the
components.
hope that this helps
shreeman
sn*********@rediffmail.com

-----Original Message-----
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 thebinary compatibility? That is, user application can run with recompilingand relinking.

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

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

Thanks.
.

Nov 22 '05 #3
"someone" <so****@somewhere.com> wrote in
news:%2****************@TK2MSFTNGP11.phx.gbl...
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.
..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 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?
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.
In pure C++, adding a data member to a class that is exposed to the user
will break compatibility.


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

Niki
Nov 22 '05 #4
"Niki Estner" <ni*********@cube.net> wrote in
news:ez****************@TK2MSFTNGP11.phx.gbl...
"someone" <so****@somewhere.com> wrote in
news:%2****************@TK2MSFTNGP11.phx.gbl...
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.
.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.


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
Nov 22 '05 #5
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" <ni*********@cube.net> wrote in message
news:ez****************@TK2MSFTNGP11.phx.gbl...
"someone" <so****@somewhere.com> wrote in
news:%2****************@TK2MSFTNGP11.phx.gbl...
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.
.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
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?


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.
In pure C++, adding a data member to a class that is exposed to the user
will break compatibility.


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

Niki

Nov 22 '05 #6
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" <so****@somewhere.com> wrote in
news:er**************@TK2MSFTNGP10.phx.gbl...
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" <ni*********@cube.net> wrote in message
news:ez****************@TK2MSFTNGP11.phx.gbl...
"someone" <so****@somewhere.com> wrote in
news:%2****************@TK2MSFTNGP11.phx.gbl...
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.


.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
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?


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.
In pure C++, adding a data member to a class that is exposed to the user will break compatibility.


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

Niki


Nov 22 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: someone | last post by:
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...
103
by: Steven T. Hatton | last post by:
§27.4.2.1.4 Type ios_base::openmode Says this about the std::ios::binary openmode flag: *binary*: perform input and output in binary mode (as opposed to text mode) And that is basically _all_ it...
3
by: pontifikas | last post by:
I've created some code, manipulating an Excel application. Unfortunately this does not work on systems with Other Office distros than Office XP. Is there something I can do to ensure...
3
by: Michi Henning | last post by:
Hi, I'm interested in figuring out exactly what kind of change to an assembly is binary compatible. I've browsed the doc a fair bit, but I can't find a comprehensive list of what actually...
14
by: frostalicious | last post by:
Used VB.NET (on my client PC) to convert VB6 executable to .NET executable. Placed the .exe file on a network drive on my server. From client, ran .NET Wizards "Trust an Assembly" to make the...
2
by: DaveP | last post by:
In Visual Basic 6.0, there was a setting for DLL's that would prevent a developer from breaking binary compatibility of a DLL by changing a function name, parameters, etc. Warnings would appear at...
68
by: vim | last post by:
hello everybody Plz tell the differance between binary file and ascii file............... Thanks in advance vim
4
by: zak | last post by:
we have a suite of products that have a number of shared assemblies. During development and support the shared assemblies code will change . I want to control the versioning, so if the code chnages...
1
by: Simon Woods | last post by:
Hi I have a dll ('dll-X') which runs on top of (dependent upon) several other dlls. My build environment has a folder structure binaries compat-libs
17
by: osama178 | last post by:
Hi, What does it mean for an object to be binary compatible? And why aren't STL objects binary compatible? Any insights, links, resources for further reading are greatly appreciated. Thanks.
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.