How to create an object using JACOB

亡梦爱人 提交于 2019-12-06 07:53:43

问题


I managed to load two dll's

    System.load("C:\\Program Files (x86)\\EXAMPLE Client\\Bin\\EXAMPLE.Client.SDK.dll");
    System.load("C:\\Program Files (x86)\\EXAMPLE Client\\Bin\\EXAMPLE.Common.SDK.dll");

Next step is to create on object calls SDKModel. How do I do this? I tried:

ActiveXComponent example = new ActiveXComponent("EXAMPLE.Common.SDK.SDKModel");

But then I get the following exception:

Exception in thread "main" com.jacob.com.ComFailException: Can't get object clsid from progid

I'm unsure whether I'm on the right track. How would create the object SDKModel?


回答1:


Its because you didn't registered your dll in system. Check path of cd in both code

To register follow [important: Be careful using regasm.exe as it different file than unregister]

c:
cd\
cd C:\Windows\Microsoft.NET\Framework64\v2.0.50727 
RegAsm /verbose /nologo /codebase D:\path_to_dll\mydll.dll

To unregister follow

c:
cd\
cd C:\Windows\Microsoft.NET\Framework\v2.0.50727
RegAsm.exe /unregister D:\path_to_dll\mydll.dll

Update:

To register / Unregister use C:\Windows\Microsoft.NET\Framework\v2.0.50727 framework..



来源:https://stackoverflow.com/questions/16144511/how-to-create-an-object-using-jacob

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!