I have a small application that generates three different template documents in
OOo Writer. When one of the three "generate" buttons is clicked, this
is part of
the code that is executed (in C#):

// Connect to OOo
if (componentContext == null)
    componentContext = uno.util.Bootstrap.bootstrap();
XMultiServiceFactory multiServiceFactory =
    (XMultiServiceFactory) componentContext.getServiceManager();
XComponentLoader loader = (XComponentLoader)
    multiServiceFactory.createInstance
        ("com.sun.star.frame.Desktop");

// Initialize class members document, text, and cursor
document = (XTextDocument) loader.loadComponentFromURL
    ("private:factory/swriter", "_blank", 0,
     new PropertyValue[0]);
text = document.getText();
cursor = text.createTextCursor();


The following steps cause a crash:

1. The user generates a document.
2. The user closes the document (closing OOo).
3. The user tries to generate another document.

This exception is thrown:
unoidl.com.sun.star.lang.DisposedException: URP-Bridge: disposed(tid=4)
Unexpected connection closure

How do I check to make sure the connection is still open before trying to
generate another chart? And how do I reconnect if it has been closed?

More specifically, this is the complete error message:
Marshaling clicked signal
Exception in Gtk# callback delegate
  Note: Applications can use GLib.ExceptionManager.UnhandledException to handle
the exception.
System.Reflection.TargetInvocationException: Exception has been thrown by the
target of an invocation. ---> unoidl.com.sun.star.lang.DisposedException: URP-
Bridge: disposed(tid=4) Unexpected connection closure
  at com.sun.star.bridges.mono_uno.UnoInterfaceProxy.ConstructReturnMessage
(Any
result, System.Object[] args, uno.Typelib.InterfaceMethodTypeDescription*
methodTD, IMethodCallMessage callmsg, Any exception) [0x00000]
  at com.sun.star.bridges.mono_uno.UnoInterfaceProxy.Invoke (IMessage request)
[0x00000]
  at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke
(System.Runtime.Remoting.Proxies.RealProxy rp, IMessage msg, System.Exception&
exc, System.Object[]& out_args) [0x00000]
  --- End of inner exception stack trace ---
...

The application was terminated by a signal: SIGHUP

If I get rid of the line "if (componentContext == null)" (i.e., always try to
connect, even when we have already connected), I get a stacktrace
accompanied by
this message:

=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================


I've tried handling the "disposing" event, and trying to reconnect
when OOo is closed (via Bootstrap.bootstrap()), but I get the same
Unexpected connection closure.  One interesting thing is that
"disposing" doesn't seem to get called for the componentContext,
multiServiceFactory, or loader when I close OOo. Only the document
calls disposing (and trying to reconnect still gives me the error).
Perhaps what's happening is that the connection is never fully closed,
and that's what makes bootstrap give the error. Any ideas?

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to