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 7822523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:56:44+00:00 2026-06-02T07:56:44+00:00

In the past I wrote a C# library to work with OpenOffice and this

  • 0

In the past I wrote a C# library to work with OpenOffice and this worked fine both in Windows than under Ubuntu with Mono.
Part of this library is published here as accepted answer.
In these days I discovered that Ubuntu decided to move to LibreOffice, so I tried my library with LibreOffice latest stable release.
While under Windows it’s working perfectly, under Linux I receive this error:

Unhandled Exception: System.TypeLoadException: A type load exception has occurred.
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: A type load exception has occurred.

Usually Mono tells us which library can’t load, so I can install correct package and everything is OK, but in this case I really don’t know what’s going bad.

I’m using Ubuntu oneiric and my library is compiled with Framework 4.0.
Under Windows I had to write this into app.config:

<?xml version="1.0"?>
<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
  </startup>
</configuration>

because LibreOffice assemblies uses Framework 2.0 (I think).

How can I find the reason of this error to solve it?
Thanks

UPDATE:
Even compiling with Framework 2.0 problem (as expected) is the same.
Problem (I think) is that Mono is not finding cli-uno-bridge package (installable on previous Ubuntu releases and now marked as superseded), but I cannot be sure.

UPDATE 2:
I created a test console application referencing cli-uno dlls on Windows (they are registered in GAC_32 and GAC_MSIL).

CONSOLE app

static void Main(string[] args)
{
    Console.WriteLine("Starting");
    string dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
    string doc = Path.Combine(dir, "Liberatoria siti web.docx");
    using (QOpenOffice.OpenOffice oo = new QOpenOffice.OpenOffice())
    {
        if (!oo.Init()) return;
        oo.Load(doc, true);
        oo.ExportToPdf(Path.ChangeExtension(doc, ".pdf"));
    }
}

LIBRARY:

using unoidl.com.sun.star.lang;
using unoidl.com.sun.star.uno;
using unoidl.com.sun.star.container;
using unoidl.com.sun.star.frame;
using unoidl.com.sun.star.beans;
using unoidl.com.sun.star.view;
using unoidl.com.sun.star.document;
using System.Collections.Generic;
using System.IO;
using System;

namespace QOpenOffice
{
    class OpenOffice : IDisposable
    {
        private XComponentContext context;
        private XMultiServiceFactory service;
        private XComponentLoader component;
        private XComponent doc;

        public bool Init()
        {
            Console.WriteLine("Entering Init()");
            try
            {
                context = uno.util.Bootstrap.bootstrap();
                service = (XMultiServiceFactory)context.getServiceManager();
                component = (XComponentLoader)service.createInstance("com.sun.star.frame.Desktop");
                XNameContainer filters = (XNameContainer)service.createInstance("com.sun.star.document.FilterFactory");
                return true;
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
                if (ex.InnerException != null)
                    Console.WriteLine(ex.InnerException.Message);
                return false;
            }
        }
    }
}

but I’m not able to see “Starting” !!!
If I comment using(…) on application, I see line on console… so I think it’s something wrong in DLL. There I’m not able to see "Entering Init()" message on Init(). Behaviour is the same when LibreOffice is not installed and when it is !!! try..catch block is not executed…
I start to think that mono cannot find LibreOffice CLI libraries…
I used updatedb and then locate to find them, but I always get an empty result; I don’t understand, on Windows everything works…

UPDATE 3:
After Hans comment, I’ve just removed everything but Init() in my library but error remained. So I moved to dynamic

//private XComponentContext context;
//private XMultiServiceFactory service;
//private XComponentLoader component;
//private XComponent doc;
//private List<string> filters = new List<string>();

#region Constructors
public OpenOffice()
{
    Console.WriteLine("Entering Init()");
    try
    {
        var context = uno.util.Bootstrap.bootstrap();
        var service = (XMultiServiceFactory)context.getServiceManager();
        var component = (XComponentLoader)service.createInstance("com.sun.star.frame.Desktop");
    }
    catch (System.Exception ex)
    {
        Console.WriteLine(ex.Message);
        if (ex.InnerException != null)
            Console.WriteLine(ex.InnerException.Message);
    }
}

and now in console I’m able to see

Starting

Unhandled Exception: System.IO.FileNotFoundException: Could not load
file or assembly ‘cli_uretypes, Version=1.0.8.0, Culture=neutral,
PublicKeyToken=ce2cb7e279207b9e’ or one of its dependencies.

This doesn’t solve my problem, but helps!!
Question is: why LibreOffice’s Linux installation (installation package + SDK) does not install this library?

  • 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-06-02T07:56:45+00:00Added an answer on June 2, 2026 at 7:56 am

    I finally answer my question, but I want to thank @Hans for helping me in finding hidden problem.
    As I wrote, trying to run a simple app with Mono using LibreOffice, I got this error

    Unhandled Exception: System.TypeLoadException: A type load exception
    has occurred.
    [ERROR] FATAL UNHANDLED EXCEPTION:
    System.TypeLoadException: A type load exception has occurred.

    There was no way to let Mono tell me which was the error, nor my app was writing anything to console so I could understand which part/line raise the error.
    A paragraph in Hans answer showed me the way

    The .NET framework has a true just-in-time compiler. Mono doesn’t, it
    has an AOT (Ahead Of Time) compiler. In other words, it aggressively
    compiles all the code in the assembly, not just what is about to be
    executed.

    So when I declare

    private XComponentContext context;
    private XMultiServiceFactory service;
    private XComponentLoader component;
    private XComponent doc;
    

    Mono tries to find referenced assemblies right when the app is executed, not when those lines are to be processed! Thinking about this, I decided to move on dynamics.
    So I removed variables declaration and used:

    //private XComponentContext context;
    //private XMultiServiceFactory service;
    //private XComponentLoader component;
    
    var context = uno.util.Bootstrap.bootstrap();
    var service = (XMultiServiceFactory)context.getServiceManager();
    var component = (XComponentLoader)service.createInstance(
        "com.sun.star.frame.Desktop");
    

    Executing my app again, I was able to see console messages I expected and finally, when line var context = ... were processed I got

    Unhandled Exception: System.IO.FileNotFoundException: Could not load
    file or assembly ‘cli_uretypes, Version=1.0.8.0, Culture=neutral,
    PublicKeyToken=ce2cb7e279207b9e’ or one of its dependencies.

    So I finally managed to find the problem: LibreOffice in Ubuntu 11.10 does not install CLI interface package and this package has been stripped off from current Ubuntu distribution.
    Even if I tried to manually install other older packages, even converting some rpm package, I was not able to use LibreOffice with Mono.
    Too bad, even because with previous distribution using OpenOffice there was cli-uno-bridge package doing this job. Hope better in future…
    I also tried to post a question at AskUbuntu, but no useful answer were given at this moment.

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

Sidebar

Related Questions

This has been driving me crazy the past few days. I wrote a program
I've used the FileHelpers.dll library found here in the past with success. In this
Past scenario - Work with Tomcat and start in debug mode and Remote Debug
Looking back at my past projects I often encounter this one: A client or
I have an application that we wrote here at work that uses the SharpSVN
In the past, I've worked a lot with 8 bit AVR's and MSP430's where
In the past, I wrote an app that would draw lines with two touches.
In the past I wrote most of my unit tests using C# even when
I wrote the CS 462 Office Hours app over the past two days. The
On a past project (pre-iOS 4.0), I wrote the following category method on NSSortDescriptor

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.