我可以在不使用COM的情况下直接使用C ++在.NET中制作DLL文件吗 [英] Can i use, C++ made DLL files in .NET directly without using COM

查看:59
本文介绍了我可以在不使用COM的情况下直接使用C ++在.NET中制作DLL文件吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设,如果我有一个在C ++中创建的DLL文件,没有使用COM

我可以直接在.NET中加载吗?

或COM是必需的??

如果我可以直接加载它,怎么办?

suppose, if i have a DLL file that i created in C++ WITHOUT using COM

Can i load it directly in .NET??

or COM is required???

if i can load it directly, then how??

推荐答案

不,不需要COM.是的,您可以在.NET应用程序中加载导出的本机DLL函数,并通过 P/Invoke平台调用服务使用它们.

请参阅:
http://en.wikipedia.org/wiki/P/Invoke [ http://msdn.microsoft.com/en-us/library/Aa712982 [ ^ ].

此CodeProject文章也可能有用:
基本P/调用 [
关于C ++/CLI,请参阅:
http://en.wikipedia.org/wiki/C%2B%2B/CLI [ ^ ],
http://www.ecma-international.org/publications/standards/Ecma-372.htm [^ ],
http://msdn.microsoft.com/en-us/library/xey702bw.aspx [ ^ ].

—SA
No, COM is not required. Yes, you can load exported native DLL functions in your .NET application and use them using Platform Invocation Services, P/Invoke.

Please see:
http://en.wikipedia.org/wiki/P/Invoke[^],
http://msdn.microsoft.com/en-us/library/Aa712982[^].

This CodeProject article can also be useful:
Essential P/Invoke[^].

An alternative approach is using C++/CLI. You can create a mixed-mode (managed+unmanaged) C++/CLI DLL. You can mix C++ with C++/CLI and wrap all native calls to your native DLL into .NET C++/CLI "ref" classes. The obtained executable can be used like a regular .NET assembly and referenced by your C# assembly.

About C++/CLI, please see:
http://en.wikipedia.org/wiki/C%2B%2B/CLI[^],
http://www.ecma-international.org/publications/standards/Ecma-372.htm[^],
http://msdn.microsoft.com/en-us/library/xey702bw.aspx[^].

—SA


这篇关于我可以在不使用COM的情况下直接使用C ++在.NET中制作DLL文件吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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