Apache OpenOffice (AOO) Bugzilla – Issue 100071
Using .NET assemblies, remote contexts return objects that can't be used
Last modified: 2013-04-19 10:46:03 UTC
1. Start soffice.exe to sit on a port soffice.exe -invisible -nofirststartwizard -minimized -nologo -nolockcheck -nodefault -headless - accept="socket,host=localhost,port=8100;urp" 2. Create a project (console application) with this code XComponentContext xLocalContext = uno.util.Bootstrap.defaultBootstrap_InitialComponentContext(); XMultiComponentFactory xLocalServiceManager = xLocalContext.getServiceManager(); XUnoUrlResolver xUrlResolver = (XUnoUrlResolver)xLocalServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", xLocalContext); XMultiServiceFactory multiServiceFactory = (XMultiServiceFactory)xUrlResolver.resolve("uno:socket,host=localhost,port=8100;urp;StarOffice.ServiceManager"); XComponentLoader componentLoader = (XComponentLoader)multiServiceFactory.createInstance("com.sun.star.frame.Desktop"); 3. The last line will throw with Unable to cast transparent proxy to type 'unoidl.com.sun.star.frame.XComponentLoader' 4. If you use a local context created with Bootstrap.bootstrap(), it will work fine, but then you cannot connect to Open Office on another machine Reported in the forum here http://www.oooforum.org/forum/viewtopic.phtml?t=77457 I have seen it as well. I spent two days trying to figure it out, but I think it's just a bug in OO.
I have confirmed that the following DLLS are in my GAC and are the ones being loaded cli_basetypes 1.0.12.0 cli_cppuhelper 1.0.15.0 cli_oootypes 1.0.1.0 cli_ure 1.0.15.0 cli_uretypes 1.0.1.0 I see that the 3.0 SDK installs a version of these that are one less in the third number. I have confirmed that these are not loaded. They are not in the GAC and I removed them from my machine to make sure they weren't loaded. I am using PROCMON.EXE and other tools to ensure that the dlls listed above are the ones loaded.
jsc -> jl: one for you
Sorry, I miscopied my soffice.exe startup. It was: soffice.exe -invisible -nofirststartwizard -minimized -nologo -nolockcheck - nodefault -headless - accept="socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" Accidentally left off StarOffice.ServiceManager at the end
I updated the Wiki at http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/CLI/Writing_Client_Programs What you need to to is open a socket from your client program, for example: System.Net.Sockets.Socket s = new Syste.Net.Sockets.Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP); This is a work around to initialize the windows socket API. Then provide an ini file, which is named as your client program (without extension). For example: client.exe -> client.ini It must contain: [Bootstrap] URE_BOOTSTRAP=file:///d:/OpenOffice.org%203/program/fundamental.ini Adapt the file URL to your local office installation. @myself: Check if cli_cppuhelper should/can call WSAStartup.
I see this same problem while using pipes rather than ports to connect. Is there a similar workaround that will work with the named pipes?
You also need to provide URE_BOOTSTRAM when using pipes and defaultBootstrap_InitialComponentContext.
Target 3.3
Retargeted to 3.x
Creating a socket with SocketType.Raw requires admin rights since Windows Vista. Please provide a workaround that does not require admin rights.
System.Net.Sockets.Socket s = new Syste.Net.Sockets.Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); seems to work as well, and doesn't require admin rights.