如何从C ++ DLL动态加载C#DLL [英] How to dynamically load a C# dll from a C++ DLL

查看:260
本文介绍了如何从C ++ DLL动态加载C#DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C ++应用程序。这支持用户的C ++插件的DLL,它会动态加载DLL这些的,然后能够动态地创建和使用用户的类型。这些用户类型从基本类型和主要应用程序的核心库定义的接口派生,所以我认为用户对象为指针的基类,并调用用户的虚拟功能,使他们的魔术发生。

I have a C++ application. This supports users' C++ plugin DLL's, it will dynamically load these DLL's and then be able to create and use the user's types dynamically. These user types derive from base types and interfaces defined in the main application's core library, so I hold user's objects as pointers to the base class and call the user's virtual functions to make their magic happen.

现在我想扩展插件DLL的允许托管DLL的(我关心C#居多)。我希望所有的同魔术在C#中的插件DLL的发生。

Now I want to extend the plugin DLL's to allow managed DLL's (I care about C# mostly). I want all of the same magic to happen in C# plugin DLL's.

我如何动态加载这些dll的,有些我怎么想的win32的,我现在使用的是要调用LoadLibrary值得高兴的与托管DLL。我将无法访问这些库在编译/链接时,他们来自用户。

How can I dynamically load these dll's, some how I think win32's LoadLibrary which I am currently using is going to be happy with a managed DLL. I will not have access to these libraries at compile/link time, they come from the user.

在我得到加载库,可惜我怀疑COM在我的将来的方法来调用导出功能。也许我可以使用CLI / C ++包装我一直在阅读有关,但我在这里非常缺乏经验,并希望任何建议或链接到相应的文章。

After I get the library loaded, unfortunately I suspect COM in my future as the way to call the derived functions. Possibly I could use the CLI/C++ wrapper I have been reading about but I am very inexperienced here and would appreciate any advice or links to appropriate articles.

推荐答案

什么你会做的基本上是启动了CLR的实例,在你的进程。
有一个看看这篇文章在 CLR托管

What you'd do is basically start up an instance of the CLR in your process. Have a look at this article on CLR hosting

这篇关于如何从C ++ DLL动态加载C#DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆