Modifying Class Library

S

Steve Baer

I've already tested this with C# and it works, but I'm being paranoid and I
wanted to also check here.

Our application has a large class library written in C++/CLI for plug-in
projects. The original library was written in C++ and the general rule for
not breaking our SDK is to not change the class size by adding member
variables and to not add virtual functions because this will change the
vtable for the class. This is fine and we know how to deal with this on the
good old native C++ side, but when it comes to the .NET class library I'm a
little confused.

It appears that I can break this rule for .NET class libraries (probably
because everything is actually in IL). Is this true that I can add virtual
functions and member variables to classes in a C++/CLI class library and not
break the functionality of assemblies that were built against the older
version of the class library?

Thanks,
-Steve

Steve Baer
Robert McNeel & Associates
 
S

Sheng Jiang[MVP]

Are you using class as your interface? Why don't you extract some interface
from your class library, so you don't need to worry about memory layout and
virtual tables?
 
S

Steve Baer

Hi Sheng,
Yes I am using both classes and interfaces. I could have gone with the
interface route for the SDK design, but chose not to for several reasons the
primary one being that this is a wrapper around our native C++ SDK and I
wanted the code to match the native C++ style as close as possible.

Even if this was a mistake in the design of the SDK for a class library, the
class library for the initial release of our product is already out there
and being used by a large number of commercial plug-in applications. So... I
really would like to understand if adding virtual functions to classes in my
library has adverse effects on the existing plug-ins.

Thanks,
-Steve

Steve Baer
Robert McNeel & Associates
 
S

Sheng Jiang[MVP]

In .net you can extend your class and add virtual functions in a way like
..Net BCL 2.0 did to .Net 1.0. .Net 1.0 assemblies can be referenced and run
in .Net 2.0 applications.
 
S

Steve Baer

Thanks!

Sheng Jiang said:
In .net you can extend your class and add virtual functions in a way like
.Net BCL 2.0 did to .Net 1.0. .Net 1.0 assemblies can be referenced and
run
in .Net 2.0 applications.
 

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