Community
Participate
Working Groups
Build Identifier: 3.6 Creating an instance of an OLE component (not embedded) fails: OleAutomation application = new OleAutomation("Excel.Application"); => org.eclipse.swt.SWTException: Failed to create Ole Client. result = -2147221164 If we change the code in the OleAutomation(String) constructor to add the "COM.CLSCTX_LOCAL_SERVER" flag, then it works: int result = COM.CoCreateInstance(appClsid, 0, COM.CLSCTX_LOCAL_SERVER | COM.CLSCTX_INPROC_SERVER, COM.IIDIUnknown, ppvObject); Reproducible: Always Steps to Reproduce: 1. new OleAutomation("Excel.Application");
Fixed in HEAD > 20100812
Same problem with a fresh install: --- Eclipse for RCP and RAP Developers Version: Helios Service Release 2 Build id: 20110218-0911 --- Why is the "COM.CLSCTX_LOCAL_SERVER" flag is still missing in my sources?
The code is not in Helios, Indigo only.
Switched to Indigo and problem remains. The COM.CLSCTX_LOCAL_SERVER flag is only added in case of excel automation: if (progId.startsWith("Excel")) flags |= COM.CLSCTX_LOCAL_SERVER; Since I work with MS Word I can tell you that it is needed for Word automation, too. Probably it's the same with all MS Office products.
Okay, I can't do anything for Indigo anymore. Lets target this for 3.8
Is it possible for this fix to come as part of a patch update. I have an application that uses Outlook as a key component. My entire office is in the process of migrating to Windows 7, and this causes a major issue for me.
Hey Bob, what version of Eclipse are you using ? Can you provide a patch for this bug ? It seems that all that is needed is to set COM.CLSCTX_LOCAL_SERVER in more cases than progId.startsWith("Excel") Is that the fix for you too ?
(In reply to comment #7) > Hey Bob, what version of Eclipse are you using ? > Can you provide a patch for this bug ? > It seems that all that is needed is to set COM.CLSCTX_LOCAL_SERVER in more > cases than progId.startsWith("Excel") > Is that the fix for you too ? I just got Indigo, and am running SWT 64-bit 3.7.1 I think that fix will work for me. The only difference with my current code is that I am making use of OleControlSite, then declaring OleAutomation(OleControlSite) Looking at that source, I don't see any of the CoCreate logic that is part of OleAutomation(String) However, if any fix can be applied, I'd take it, if there is no workaround. I would hate to re-tool all my OLE code to use some other means.
Robert, the fix suggested here goes in: OleAutomation(String) If you are saying you are not using the method then how is this going to help you ? Try to get SWT source and try differents fixes ? See http://www.eclipse.org/swt/git.php You can also attach the snippet to this bug (or open a new one) so I can try to reproduce your problem. The sooner I'll have time to look into this is next week.
(In reply to comment #9) > Robert, the fix suggested here goes in: > OleAutomation(String) > If you are saying you are not using the method then how is this going to help > you ? > Try to get SWT source and try differents fixes ? > See http://www.eclipse.org/swt/git.php > You can also attach the snippet to this bug (or open a new one) so I can try to > reproduce your problem. The sooner I'll have time to look into this is next > week. I figured how to export as a jar, but I am running Windows 7 64 bit. How do I export the SWT as 64 bit?
> I figured how to export as a jar, but I am running Windows 7 64 bit. How do I > export the SWT as 64 bit? it would probable be easier to run with 32bit eclipse on a 32bit VM. Anyhow, get the bundle org.eclipse.swt.win32.win32.x86_64 (instead of org.eclipse.swt.win32.win32.x86) and export that as Deployable plug-ins and fragments. I think that should take care of the 32->64 java code conversion before compiling and packing all up. it that doesn't work try running the task replace.32.to.64 in org.eclipse.swt/buildSWT.xml and then export the jars the usual way.
Hello, This bug is alwais present in Helios RCP distibution : org.eclipse.swt.SWTException: Failed to create Ole Client. result = -2147221164 at org.eclipse.swt.ole.win32.OLE.error(OLE.java:302) at org.eclipse.swt.ole.win32.OleAutomation.<init>(OleAutomation.java:159) With this code : OleAutomation outlook = new OleAutomation("Outlook.Application"); Is a correction planned for other MS applications?
Kepler RCP distribution, sorry for the mistake...
Any update on this case? Solving this is very easy. Just do following: (simple, retains backward compatibility, and do the job) public OleAutomation(String progId, int flags) { initialize(progId, flags); } public OleAutomation(String progId) { int flags = COM.CLSCTX_INPROC_SERVER; if (progId.startsWith("Excel")) flags |= COM.CLSCTX_LOCAL_SERVER; initialize(progId, flags); } public void initialize(String progId, int flags) { try { OS.OleInitialize(0); GUID appClsid = getClassID(progId); if (appClsid == null) { OS.OleUninitialize(); OLE.error(OLE.ERROR_INVALID_CLASSID); } long /*int*/[] ppvObject = new long /*int*/[1]; int result = COM.CoCreateInstance(appClsid, 0, flags, COM.IIDIUnknown, ppvObject); if (result != COM.S_OK) { OS.OleUninitialize(); OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result); } objIUnknown = new IUnknown(ppvObject[0]); ppvObject[0] = 0; result = objIUnknown.QueryInterface(COM.IIDIDispatch, ppvObject); if (result != COM.S_OK) OLE.error(OLE.ERROR_INTERFACE_NOT_FOUND); objIDispatch = new IDispatch(ppvObject[0]); ppvObject[0] = 0; result = objIDispatch.GetTypeInfo(0, COM.LOCALE_USER_DEFAULT, ppvObject); if (result == OLE.S_OK) { objITypeInfo = new ITypeInfo(ppvObject[0]); } } catch (SWTException e) { dispose(); throw e; } }
(In reply to Zygmunt Horodyski from comment #14) > Any update on this case? Solving this is very easy. Just do following: > (simple, retains backward compatibility, and do the job) > Do you have a test snippet handy, which reproduces this problem ?
something simple like that: import org.eclipse.swt.ole.win32.OleAutomation; import org.junit.Test; public class OleAutomationTest { @Test public void testThatLocalServerApplicationIsAccessible() { new OleAutomation("Outlook.Application"); // No error has occurred } } Actually, I'm not using Outlook.Application in my case but company software, but this two has the same problem.
(In reply to Zygmunt Horodyski from comment #16) > something simple like that: > > > import org.eclipse.swt.ole.win32.OleAutomation; > import org.junit.Test; > > public class OleAutomationTest { > > @Test > public void testThatLocalServerApplicationIsAccessible() { > new OleAutomation("Outlook.Application"); > > // No error has occurred > } > > } > > > Actually, I'm not using Outlook.Application in my case but company software, > but this two has the same problem. Same here, I'm also not using Outlook.. Please suggest any alternate out there in open/public to try ?
There are also applications like InternetExplorer.Application.1 Easiest way to find application that needs to be started as COM.CLSCTX_LOCAL_SERVER is to open registry and under HKEY_CLASSES_ROOT\CLSID search for LocalServer32 and if you will find one then if there is folder ProgID you can read its progId there.
Any update here?
Problem still exists in Neon. I work on a project with Outlook. Version 2016 works but with Outlook 2010 the error occurs. Passing the flag COM.CLSCTX_LOCAL_SERVER still does the trick. Outlook 2016 still works. Unfortunately OleAutomation is a final class. Currently there is no other way than copy some OLE java-sources into the project to pass the flag. Another conctructor to pass the COM.CLSCTX_LOCAL_SERVER flag will be helpful as a workaround.
Created attachment 273554 [details] PR318942_Example.java Local COM server access example: open eclipse.org in a separate MSIE window using SHDocVw.InternetExplorer object.
New Gerrit change created: https://git.eclipse.org/r/121062
Gerrit change https://git.eclipse.org/r/121062 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=66bbce07c55f39dcf5080ace1ab49e9e4c9f379c
Thanks Nikita for the patch. Would it be possible to add a test for Windows to ensure this will also work in future versions?