目录
2.2将jacob-1.18-x64.dll放到C:\Windows\System32文件夹下
4.1com.jacob.com.ComFailException: Can't map name to dispid
4.2com.jacob.com.ComFailException: Can't co-create object
4.3com.jacob.com.ComFailException: Can't get object clsid from progid
1.编写DLL
1.1新建项目(Visual Studio)
1.2编写测试用例
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyTest
{
public class TestClass
{
/**
* public TestClass()测试用例 传入两个整数,返回两个整数之和
* 此方法不能用static修饰,不然在java端调用时会报错
* com.jacob.com.ComFailException: Can't map name to dispid:sum
*/
public int sum(int a, int b) {
int tem = a + b;
return tem;
}
}
}
1.3生成解决方案,导出DLL
以下设置必须要有,不然会在注册dll的时候不提示“成功注册了类型”
生成-生成解决方案
1.4第一次生成解决方案时报错的处理办法
1.4.1出现“无法注册程序集dll- 拒绝访问。请确保您正在以管理员身份运行应用程序。对注册表项的访问被拒绝
WIN+R,运行对话框中输入gpedit.msc,开启