如何在 java eclipse 插件中使用自定义 OLE dll?

How to use a custom OLE dll in a java eclipse plugin?

我正在尝试将自定义 OLE dll 与我的 Eclipse RCP 插件中的控件一起使用。

dll 在我的工作目录中,但如果我尝试使用它,我会收到 SWTException:

我使用这个代码:

Display display = Display.getCurrent();
Shell shell = new Shell(display);
OleFrame frame = new OleFrame(shell, SWT.NONE);
OleClientSite site = new OleClientSite(frame, SWT.NONE, "MyCustomDll.TestControl");
OleAutomation test = new OleAutomation(site);
shell.open();

并得到这个异常:

org.eclipse.swt.SWTException: Class ID not found in registry
  at org.eclipse.swt.ole.win32.OLE.error(OLE.java:317)
  at org.eclipse.swt.ole.win32.OLE.error(OLE.java:283)
  at org.eclipse.swt.ole.win32.OleClientSite.<init>(OleClientSite.java:226)
  ...

如何告诉我的插件到哪里寻找 Class ID? 一定有一些我遗漏的基本要点,但我没有找到任何关于使用自定义 OLE dll 的信息。

经过大量尝试和错误后,我找到了问题的解决方案:

我的 Dll 注册于:

C:\Windows\Microsoft.NET\Framework64\v2.0.50727\regasm

相反,我注册了它:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regasm

它奏效了。反正我也不知道为什么会有不同的版本。