Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 578037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:13:05+00:00 2026-05-13T14:13:05+00:00

Here is a sample application that creates a Window with a single Button inside.

  • 0

Here is a sample application that creates a Window with a single Button inside. When clicked, it connects to OOo (if not already connected) and creates a text document.

This works fine unless all the documents created in OOo are closed. Then, I get a DisposedException when trying to create the next chart. This is understandable, but OOo has been closed. However, trying to reconnect at this point gives me a segfault. Is there a better way to reconnect? I am working on linux (Ubuntu).

Note: This connects properly to OOo even if OOo is not open. It’s once OOo has been opened by the application, then closed that we get the error.

All you really need to look at is the Connect method. I just wrapped it in a Gtk interface for easy testing.

using System; 
using unoidl.com.sun.star.uno; 
using unoidl.com.sun.star.lang; 
using unoidl.com.sun.star.text; 
using unoidl.com.sun.star.frame; 
using unoidl.com.sun.star.beans; 
using Gtk; 

namespace TestOOo { 
   class MainClass { 
      static XComponentContext componentContext; 
      static XMultiServiceFactory multiServiceFactory; 
      static XComponentLoader loader; 
      static XTextDocument document; 

      public static void Main (string[] args) 
      { 
         Application.Init(); 

         Window mainWindow = new Window("Test Window"); 
         mainWindow.Visible = true; 
         mainWindow.Destroyed += delegate { Application.Quit(); }; 
         Button button = new Button(Stock.Ok); 
         button.Clicked += delegate { Connect(); }; 
         mainWindow.Add(button); 
         mainWindow.ShowAll(); 

         Application.Run(); 
      } 

      static void Connect() 
      { 
         // Connect to OOo 
         if (componentContext == null) 
            componentContext = uno.util.Bootstrap.bootstrap(); 

         try { 
            multiServiceFactory = 
               (XMultiServiceFactory) componentContext.getServiceManager(); 
         } catch { 
            // This is where we want to reconnect, but trying to 
            // bootstrap() again segfaults. 

            // componentContext = uno.util.Bootstrap.bootstrap(); 
            // multiServiceFactory = 
            //   (XMultiServiceFactory) componentContext.getServiceManager(); 
         } 

         loader = (XComponentLoader) 
            multiServiceFactory.createInstance("com.sun.star.frame.Desktop"); 
         document = (XTextDocument) loader.loadComponentFromURL 
            ("private:factory/swriter", "_blank", 0, new PropertyValue[0]); 
      } 
   } 
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T14:13:06+00:00Added an answer on May 13, 2026 at 2:13 pm

    I was never able to figure this out, but I did find a way to hack around it:

    I created a separate executable to do the generating. My main application then calls this executable, passing it the necessary parameters (just a path to the file to generate from, and the mode to generate in).

    Since the crash only occurs when OOo has been closed since the application started running (and generated at least one chart), this avoids the whole issue. It’s a very ugly hack, but it gets the job done.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

enter code here Hi All, I have a simple windows service application that connects
I have a simple application that has a single page with a button that
I've downloaded a sample application sending email silverlight application here. via gmail. But I
Here is the sample code that I ran on Visual Studio 2010: #include <iostream>
I have a borderless Windows Forms application. The main window creates other forms (simple
I have a web application that creates directories. The application works fine when creating
I have a very simple Win32 application that uses CAtlExeModuleT. The module simply creates
Here is a simple application that handled CTRL + C signal both on linux
Here’s the situation: We have a 3rd party application that intermittently displays an error
Here's sample model classes, which being use with Entity Framework Code First: public class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.