Bootstrap Uno API LibreOffice异常 [英] Bootstrap Uno API LibreOffice exception

查看:454
本文介绍了Bootstrap Uno API LibreOffice异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用以下代码:

static void Main()
{
    try
    {
        var context = uno.util.Bootstrap.bootstrap();
    }
    catch (Exception ex)
    {
       Console.WriteLine(ex.toString());
    }
}

我可以启动LibreOffice的Writer。这可以在版本4.4.4中正常工作,但在安装5.0.0版本后,使用新的SDK Bootstrap.bootstrap()抛出异常:

I can start Writer of LibreOffice. This works fine with Version 4.4.4 but after installing version 5.0.0 and with new SDK Bootstrap.bootstrap() throws the exception:

外部组件已抛出异常

有没有人面临同样的问题或某些解?
(.NET 4.0,Windows 7 64位,LibreOffice 5.0 Lite)

Has anyone faced the same problem or some solution? (.NET 4.0, Windows 7 64-bit, LibreOffice 5.0 Lite)

推荐答案

我已经设法解决在开始 soffice.exe 服务器之前设置 UNO_PATH 环境变量的问题:

I have managed to solve the problem by setting the UNO_PATH environment variable before starting the soffice.exe server:

using static System.Environment;

var unoPath = @"C:\Program Files\LibreOffice 5\program"
// when running 32-bit LibreOffice on a 64-bit system, the path will be in Program Files (x86)
// var unoPath = @"C:\Program Files (x86)\LibreOffice 5\program"

SetEnvironmentVariable("UNO_PATH", unoPath, EnvironmentVariableTarget.Process);
SetEnvironmentVariable("PATH", GetEnvironmentVariable("PATH") + @";" + unoPath, EnvironmentVariableTarget.Process);

这是必需的,因为LibreOffice 5的程序目录没有URE子目录(以前的版本)这是UNO层所必需的。

This was required because LibreOffice 5's program directory does not have "URE" subdirectory anymore (previous versions did) which is required for UNO layer.

这篇关于Bootstrap Uno API LibreOffice异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆