OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

How do I check if my XComponentContext has been closed?

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
matthewp
General User
General User


Joined: 02 Jan 2009
Posts: 19

PostPosted: Sun Nov 08, 2009 11:38 am    Post subject: How do I check if my XComponentContext has been closed? Reply with quote

Discussion on Stack Overflow
Issue in OOo Bug Tracker

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#):

Code:
         // 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:
Code:
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?

Edit: More specifically, this is the complete error message:

Code:
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 ---
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000]
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000]
  at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x00000]
  at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) [0x00000]
  at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000]
  at GLib.Signal.ClosureInvokedCB (System.Object o, GLib.ClosureInvokedArgs args) [0x00000]
  at GLib.SignalClosure.Invoke (GLib.ClosureInvokedArgs args) [0x00000]
  at GLib.SignalClosure.MarshalCallback (IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data) [0x00000]
   at GLib.ExceptionManager.RaiseUnhandledException(System.Exception e, Boolean is_terminal)
   at GLib.SignalClosure.MarshalCallback(IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data)
   at Gtk.Application.gtk_main()
   at Gtk.Application.Run()
   at TestDrive.MainClass.Main(System.String[] args) in /home/matthew/Dropbox/OpenSBS-mono/TestDrive/Main.cs:line 28

The application was terminated by a signal: SIGHUP


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

Code:
=================================================================
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.
=================================================================


Last edited by matthewp on Sun Nov 15, 2009 10:55 am; edited 1 time in total
Back to top
View user's profile Send private message
matthewp
General User
General User


Joined: 02 Jan 2009
Posts: 19

PostPosted: Sat Nov 14, 2009 11:17 am    Post subject: Reply with quote

I edited the question to add more information. I wonder if it could be a problem in the actual boostrap() method?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group