普通C ++到.net兼容程序集 [英] plain c++ to .net compatible assembly
本文介绍了普通C ++到.net兼容程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
朋友,
我正在尝试将纯C ++代码int .dll文件转换为在C#项目中使用.当我添加对* .dll的引用时,我收到以下消息(我是用普通的c ++编写的)
无法添加对'D:\ ... \ ... \ CLAHE.dll的引用.请确保该文件可访问,并且是有效的汇编或COM组件".
请帮助如何做.
谢谢
Hi Friends,
I am trying to convert plain c++ code int .dll file to be used in c# project. I recieve following message when I add reference to the *.dll (I have made from plain c++)
"A reference to ''D:\...\...\CLAHE.dll'' could not be added. please make sure that the file is accessible, and a valid assemble or COM Component".
Please help how to do it.
Thank you
推荐答案
不,您不能这样做.引用仅引用程序集.要使用非托管DLL,您需要通过System.Runtime.InteropServices
使用P/Invoke.请参阅 http://msdn.microsoft.com/en-us/library/system.runtime .interopservices.aspx [ ^ ].
您可以在此处找到详细的说明和基本代码示例: http://en.wikipedia.org/wiki/P/Invoke [ ^ ].
有关更多信息,请学习以下内容:
http://msdn.microsoft.com/en-us/library/sd10k43k.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/26thfadc.aspx [ ^ ].
[ImportDll
]的某些情况可能非常复杂.如果您真的迷路了,请尝试在CodeProject上寻求帮助,并报告问题的所有详细信息.在许多情况下,我们帮助找到了目标.
—SA
No, you cannot do it. References only reference assemblies. To use unmanaged DLL you need to use P/Invoke viaSystem.Runtime.InteropServices
. See http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.aspx[^].
You can find detailed explanation and basic code samples here: http://en.wikipedia.org/wiki/P/Invoke[^].
For more information, learn this:
http://msdn.microsoft.com/en-us/library/sd10k43k.aspx[^],
http://msdn.microsoft.com/en-us/library/26thfadc.aspx[^].
Some cases of [ImportDll
] can be rather complex. If you''re really lost, try to seek help at CodeProject and report all the details of the problem; in many cases we helped to find ends.
—SA
您好,
您可以点击此链接并解决您的问题
http://msdn.microsoft.com/en-us/library/system.runtime. interopservices.aspx [ ^ ]
在此处查找与dll相关的教程并提供帮助- http://msdn.microsoft.com/zh-CN/library/26thfadc.aspx [ ^ ]
Hello,
You can follow this link and solve your problem
http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.aspx[^]
Find dll related tutorials and help here - http://msdn.microsoft.com/en-us/library/26thfadc.aspx[^]
这篇关于普通C ++到.net兼容程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文