开发者

Native C++ Exe communicating with C# library

I have a following problem:

  1. Exe (native C++) implements interfaces Ia and Ib.
  2. 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.
  3. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜