using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace MyLib
{
[Guid("115F40AB-3F24-49A1-9FC3-0C8BAB6173D0")]
public interface IMyClass
{
int iadd(int a, int b);
float ladd(float a, float b);
}
[Guid("2C5B7580-4038-4d90-BABD-8B83FCE5A467")]
[ClassInterface(ClassInterfaceType.None)]
public class MyClass : IMyClass
{
public int iadd(int a, int b)
{
int c = 0;
c = a + b;
return c;
}
public float ladd(float a, float b)
{
float c = 0;
c = a + b;
return c;
}
}
}
如上所示 C# 简单DLL 代码
注意点:
1.项目属性-生成-为com互操作注册打上勾
2.修改Properties目录下AssemblyInfo.cs中的ComVisible属性为true
3.项目属性-签名-勾上为程序集签名-选择新建-随意输入一个名字-去掉密码保护
4.Guid由工具创建Guid
限制:
1.需要安装.net环境
易语言调用
注意点:
1.对象调用方式 XX.创建(项目名.类名,DLL路径)
版权声明:本文为chencong5025原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。