Issue 100071 - Using .NET assemblies, remote contexts return objects that can't be used
Summary: Using .NET assemblies, remote contexts return objects that can't be used
Status: ACCEPTED
Alias: None
Product: App Dev
Classification: Unclassified
Component: api (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: PC (x86_64) Windows XP
: P3 Trivial
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-09 21:38 UTC by loumf
Modified: 2013-04-19 10:46 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description loumf 2009-03-09 21:38:52 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.
Comment 1 loumf 2009-03-09 21:48:04 UTC
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.
Comment 2 jsc 2009-03-10 10:11:57 UTC
jsc -> jl: one for you
Comment 3 loumf 2009-03-10 13:18:39 UTC
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
Comment 4 joachim.lingner 2009-03-12 13:06:34 UTC
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.
Comment 5 cdownie 2009-03-25 22:21:35 UTC
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?
Comment 6 joachim.lingner 2009-03-26 09:57:30 UTC
You also need to provide URE_BOOTSTRAM when using pipes and
defaultBootstrap_InitialComponentContext.
Comment 7 joachim.lingner 2009-09-03 10:01:08 UTC
Target 3.3
Comment 8 joachim.lingner 2010-02-09 10:01:35 UTC
Retargeted to 3.x
Comment 9 matthewk 2013-04-18 20:22:08 UTC
Creating a socket with SocketType.Raw requires admin rights since Windows Vista. Please provide a workaround that does not require admin rights.
Comment 10 matthewk 2013-04-19 10:46:03 UTC
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.