你可以从C DLL调用C#DLL吗? [英] Can you call a C# DLL from a C DLL?
问题描述
最直接的方式是将C#DLL中的一个C#类公开为COM对象,然后从C / C ++ DLL中创建一个实例。如果这不是可接受的选项,您需要创建一个混合模式的C ++ DLL(其中包含托管和非托管代码)。您的C / C ++ DLL可以调用混合模式DLL中的导出函数,这可以将调用转移到C#类。
I've built a DLL in C#. Now I want to use the R Environment to call functions in that DLL. The R environment supports calling unmanaged C/C++ DLL's but not into .NET DLL's. So my question is, can I call functions in a C# DLL from a C/C++ DLL? If so, do you have a link to info about how to do this?
The most straight forward way of doing this is to expose one of the C# classes in your C# DLL as a COM object, and then create an instance of it from your C/C++ DLL. If that isn't an acceptable option, you'd need to create a mixed-mode C++ DLL (which contains both managed and unmanaged code). Your C/C++ DLL can call exported functions in your mixed-mode DLL, which can in turn forward the calls on to your C# class.
这篇关于你可以从C DLL调用C#DLL吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!