如何在vc++中使用c#Dll? [英] How to use c# Dll in vc++?
本文介绍了如何在vc++中使用c#Dll?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用命令行 (csc) 创建了一个 dll.假设 dll 包含 Add(int,int) 方法.现在我想在 vc++ 中使用那个 add 函数??
I have created a dll using command line (csc). Suppose that dll contains Add(int,int) method. Now I want to use that add function in vc++??
如何做到这一点?
您的帮助将不胜感激.
这就是我正在做的事情.
Here is what I am doing.
vcproj;对于这个项目,我有右键单击和链接器部分添加其他依赖项.添加了 dll 所在的路径.
vcproj; for this project i have right click and linker section add additional dependencies.added the path where dll resides.
main.cpp
using namespace Test
void main()
{
demo d;
d.add(5,5);
}
错误命名空间测试不存在.
如何解决这个问题?
我需要在非托管代码中使用那个 dll
I need to use that dll as in unmanaged code
推荐答案
您的 C# 程序集需要 ComVisible 属性(以及其他一些东西).
Your C# assembly needs the ComVisible attribute (among a few other things).
[assembly: ComVisible(true)]
这篇关于如何在vc++中使用c#Dll?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文