15,471
社区成员
发帖
与我相关
我的任务
分享
链接成功,以下是使用的方法:
项目属性中打开CLR开关
在头文件中加入
#using <mscorlib.dll>
#using "动态库名称"
using namespace 命名空间;
//在需要使用的函数前加入
#pragma managed
① 声明为实体无法在全局中声明,出现提示,这一点我认为是因为我这个类继承了两个基类有关系
错误 2 error C3076: you cannot embed an instance of a reference type, 'XXXDLL::XX', in a native type
如果声明为指针实体
错误 2 error C3265: cannot declare a managed 'p3' in an unmanaged 'CXXXX'
② 调用函数时参数无法通过编译
我所调用的DLL的函数有两个参数,一个是GraphicPath,一个是INT
对方在VB中给的示范是这样的
Dim Path As New System.Drawing.Drawing2D.GraphicsPath()
CLASS.FUNCTION(Path, 3)
我是这样写的
GraphicsPath graphicPath;
CLASS.FUNCTION(&graphicPath, 3);
出现错误提示如下
错误 2 error C2664: 'CLSS::FUNCTION': cannot convert parameter 2 from 'int' to 'int'
错误 1 error C3624: 'System::Drawing::Drawing2D::GraphicsPath': use of this type requires a reference to assembly 'System.Drawing'
GraphicsPath ^ p2 = gcnew GraphicsPath ();
CLASS.FUNCTION( p2 , 3 );
调用函数时参数无法通过编译
所调用的DLL的函数有两个参数,一个是GraphicPath,一个是INT
对方在VB中给的示范是这样的
Dim Path As New System.Drawing.Drawing2D.GraphicsPath()
CLASS.FUNCTION(Path, 3)
我是这样写的
GraphicsPath graphicPath;
CLASS.FUNCTION(&graphicPath, 3);
出现错误提示如下
错误 2 error C2664: 'CLSS::FUNCTION': cannot convert parameter 2 from 'int' to 'int'
错误 1 error C3624: 'System::Drawing::Drawing2D::GraphicsPath': use of this type requires a reference to assembly 'System.Drawing'
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ClassLibrary1
{
public class Class1
{
public void func()
{
Console.WriteLine( "Hello" );
}
}
}
using namespace ClassLibrary1;
int _tmain(int argc, _TCHAR* argv[])
{
Class1^ p = gcnew Class1();
p->func();
return 0;
}