Inherit unmanaged c++ classes from .Net platform (managed c++ or c#) 
Author Message
 Inherit unmanaged c++ classes from .Net platform (managed c++ or c#)

I have an old c++ network library and one of the class (socket
listener) has some virtual (or abstract) functions which should be
inherited (or implemented) by application developers. Now I'd like to
use this library from C#. I did some research and seems there is
nowhere talking about this. It's easy and straightforward to invoke
the methods of unmanaged c++ classes by wrapping them with managed
c++, but how to do this callback (virtual) polimorphism stuff?

In the "Managed Extensions for C++ Migration Guide", it's saying that
"Techniques for wrapping virtual functions, and wrapping in the
presence of inheritance are not covered here", so where can I find
such information? Or is it possible at all? Or I have to create
another unmanaged c++ lib which contains the concrete class doing the
real work and then callback to managed c++ or c#?

Any help? Thanks.

fy



Tue, 24 May 2005 01:06:24 GMT  
 Inherit unmanaged c++ classes from .Net platform (managed c++ or c#)
fy,

    The best bet would be to mark the wrapper for your method in the same
way that your method on the unmanaged class is declared.  So if your
unmanaged method was virtual, then your wrapper would be virtual, and the
wrapper just calls the unmanaged code.  That's about the best you can do, I
think

    Hope this helps.

--
               - Nicholas Paldino [.NET/C# MVP]


Quote:
> I have an old c++ network library and one of the class (socket
> listener) has some virtual (or abstract) functions which should be
> inherited (or implemented) by application developers. Now I'd like to
> use this library from C#. I did some research and seems there is
> nowhere talking about this. It's easy and straightforward to invoke
> the methods of unmanaged c++ classes by wrapping them with managed
> c++, but how to do this callback (virtual) polimorphism stuff?

> In the "Managed Extensions for C++ Migration Guide", it's saying that
> "Techniques for wrapping virtual functions, and wrapping in the
> presence of inheritance are not covered here", so where can I find
> such information? Or is it possible at all? Or I have to create
> another unmanaged c++ lib which contains the concrete class doing the
> real work and then callback to managed c++ or c#?

> Any help? Thanks.

> fy



Tue, 24 May 2005 01:33:03 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. managed C++ wrapper around unmanaged C++ classes: causing StackOverflow exception

2. debugging unmanaged c++ from a managed c++ class library

3. Managed C++ wrappers for unmanaged C++ classes

4. C++ Dot net: calling managed method from unmanaged code

5. Performance of unmanaged C++ in a managed C++ app

6. Fatal Error C1010 in Mixing Managed C++ and Unmanaged C++ Code

7. Help me!! wrap unmanaged class with managed c++

8. Referencing data from unmanaged code to managed code in C++ Wrapper class

9. C# client crashs when calling into Managed C++ which calls unmanaged c++ function

10. managed c++ vs unmanaged c++

11. How to declare a managed class pointer from unmanaged c++

12. How to pass a function pointer from Managed C++ to unmanaged c++

 

 
Powered by phpBB® Forum Software