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

  • SEARCH
  • Home
  • 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

Ask A Question

Stats

  • Questions 374k
  • Answers 374k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer First, you should use the jQuery addClass() method. You don't… May 14, 2026 at 7:54 pm
  • Editorial Team
    Editorial Team added an answer I finally figured it out. I needed to do this… May 14, 2026 at 7:54 pm
  • Editorial Team
    Editorial Team added an answer You can ask gcc to warn you when you jump… May 14, 2026 at 7:54 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.