"bootstrap handle cannot be initialized" error when working with LibreOffice in .NET Core?

121 views Asked by At

I'm attempting to work with LibreOffice using .NET Core, but I'm encountering an error that says 'bootstrap Handle is not initialized .

using unoidl.com.sun.star.uno; 
m_xContext = uno.util.Bootstrap.bootstrap();

' I've tried to clone the source code and debug it myself, but it's quite complex, and I always seem to hit a dead end. After some investigation, I realized that the pointer is always null.

I came across an article online at https://kenbonny.net/consuming-a-c-dll-in-dotnet-core and tried using the following code:

private static extern bool FreeLibrary(IntPtr libraryReference);
[DllImport("C:\\development\\libreoffice-uno-dotnet-main\\DLL\\cli_cppuhelper.dll", EntryPoint = "defaultBootstrap_InitialComponentContext", SetLastError = true, CallingConvention = CallingConvention.Cdecl)]

However, I consistently receive an error stating that the method cannot be found. I also attempted the following code:

var registerPointer = GetProcAddress(_dllPointer, "defaultBootstrap_InitialComponentContext");
if (registerPointer == IntPtr.Zero)
    throw new System.Exception("Something went wrong!");
// dotnet 4.X aka full framework
var registerCallback = (RegisterCallback)Marshal.GetDelegateForFunctionPointer(registerPointer, typeof(RegisterCallback));
var registerResult = registerCallback(_keepAlive);

But I still encounter the issue that the pointer is null. Has anyone tried to find a solution for using LibreOffice with .NET Core or found any workarounds?

It's important to note that integrating complex software like LibreOffice with .NET Core may require extensive expertise and is not always straightforward due to compatibility and technical challenges.

1

There are 1 answers

0
Jim K On

First, build the C# SDK example with a standard setup on Windows. Start with .NET 4.8, and once you have that working, see if it will work on 6.0 and Core. I have gotten the C# SDK example to work in the past, although I haven't tried with the most recent .NET version.

If the cause is a known bug, then that's the answer, and there's no need to ask about it further. The best thing you can do is add your email to the bug's CC list, or else possibly hire someone to work on the bug.

Java integration with LibreOffice is better tested and more reliable than .NET, so maybe that is an alternative to consider.