开发者

Make a .net plugin for MFC application?

I need to write a plug-in for a MFC application:

- plug-in is deployed as dll.

- On the runtime, the MFC application will call the plugin and the plugin shows a custom dialog.

- the dll needs to be dynamically loaded, the MFC application should not be re-complied if the dll is updated.

I mainly code in .net and after playing with MFC, everything just seems too odd for me (no events/delegates etc). I'm fine to write a MFC dll but if I can do that in .net then I'll willing to give it a try. A possible solution is that I can write a C# dll and expose it as COM. Since I don't know anything about COM, here are my questions:

- Does the .net framework needs to be installed on client's machine?

- Can COM be dynamically loaded from a MFC application?

- I read something about registering the assembly with COM, does this happen on client's machine? (if yes, then the installer might need to be updated) - Is it easy to use COM in a MFC application (this requires MFC devs to modify their code)

Or, given if there is too much effort to make the connection between .net, COM and MFC, would you suggest me to code in M开发者_如何学GoFC? Thanks.

UPDATE:

I decide to use C++/CLI as a bridge between MFC and .Net. A mixed C++/CLI dll can be called from MFC application and the dll can utilize .net framework. Thus I can code the UI with C# in another dll and that dll can be called by C++/CLI.

References:

  1. Native and .NET Interoperability
  2. Integrate Windows Forms Into Your MFC Applications Through C++ Interop


Does the .net framework needs to be installed on client's machine?

Yes the frame work must be installed on the client's machine

Can COM be dynamically loaded from a MFC application?

It can, the MFC application will load your DLL dynamically, it can call it without being updated as long as your class's public interface doesn't change

I read something about registering the assembly with COM, does this happen on client's machine? (if yes, then the installer might need to be updated)

Yes the .NET COM object (or any COM object for that matter) must be registered on the client's machine. You can use the building setup project in Visual Studio do to that

Is it easy to use COM in a MFC application (this requires MFC devs to modify their code)

It should be reasonably easy, but that's more a question for the MFC dev's

Would you suggest me to code in MFC

Do you know C++ or MFC? If not it's probably a lot more work.

Another option would be to write the component in C++/CLR. It can expose unmanned functions/classes which would be directly callable from the MFC application.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜