Calling managed code from unmanaged C++
-
Hi I currently use an implementation of the GoF observer pattern in C++. i.e. my observing class connects to a subject and then receives updates when it changes state. Having now waded into the Managed C++ arena I find the need to propagate the update call up into Managed C++ world from Unmanaged. My observers inherit from a class much like this: class Observer { public: virtual void Update(void) = 0; } I would love to be able to do the following: __gc class MyObserver : public Observer { ... } problem solved, but no, __gc classes cannot inherit from __nogc classes. I would like to find an approach which mimicks my existing technique as closely as possible. Thanks
-
Hi I currently use an implementation of the GoF observer pattern in C++. i.e. my observing class connects to a subject and then receives updates when it changes state. Having now waded into the Managed C++ arena I find the need to propagate the update call up into Managed C++ world from Unmanaged. My observers inherit from a class much like this: class Observer { public: virtual void Update(void) = 0; } I would love to be able to do the following: __gc class MyObserver : public Observer { ... } problem solved, but no, __gc classes cannot inherit from __nogc classes. I would like to find an approach which mimicks my existing technique as closely as possible. Thanks
You might read this information from MSDN: Interoperation with Unmanaged Code[^] Also, here's more: Interoperability in Managed Extensions for C++[^] Interop is a complex subject. It kind of depends on what exactly you want to Interop with. Is this a compiled DLL? A COM type library? Or, just a bunch of text source code? Most importantly are the data types compatible? If it was me, I'd just rewrite everything in .NET framework.