Native C++ Exe communicating with C# library
I have a following problem:
- Exe (native C++) implements interfaces Ia and Ib.
- Dll1 (native C++) has a template class
D<T>
, that implements interface Ic and calls into 3. Exe's Ia's and Ib's implementations. - Dll2 (native C++) implements a class E (class E : public
D<E>
)
At run-time happens following: Exe loads Dll2 (several instances) and instantiates E providing it with pointers to its Ia and Ib pointers. Exe "obtains" Ic pointer from Dll2.
Now, I have to allow implementation of Dll2(s) in C# so that Exe can call into Dll2's Ic impl. and Dll2 cann call back to Exe's Ia and Ib i-faces. Further restriction that I don't have to recompile Exe and Dll1 each time when new Dll2 im开发者_如何学JAVAplementation pops up.
Is it possible to implement something like this ?
I think you are going to have to move away from inheritance which is already a rather fragile tool when applied across module boundaries.
I'd point you towards COM. Managed code can expose their interfaces as COM objects and C++ can consume them. And vice versa.
精彩评论