Created attachment 200577 [details] Source Code I am trying to export word file to pdf via NET UNO API (net_bootstrap.dll,net_uno.dll) with applied filters. Used NET-Framework is 8.0. I am always getting an AccessViolation: System.AccessViolationException HResult=0x80004003 Nachricht = Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Quelle = <Die Ausnahmequelle kann nicht ausgewertet werden.> Stapelüberwachung: <Die Ausnahmestapelüberwachung kann nicht ausgewertet werden.> This is the client test code i am using. LibreOffice is locally compiled (becaus of missing net bindings in official release. see https://bugs.documentfoundation.org/show_bug.cgi?id=165585 ). I tried to use official release 25.2.2 and copied missing net comonents to the program-directory, but issue is the same. [CODE] string strDoc; XDesktop desktop = null; XComponent doc = null; strDoc = @"file:///f:/test.docx"; try { XComponentContext context = NativeBootstrap.bootstrap(); XMultiComponentFactory factory = context.getServiceManager(); desktop = Desktop.create(context); XComponentLoader componentLoader = desktop.query<XComponentLoader>(); PropertyValue[] loadProps = new PropertyValue[2]; loadProps[0] = new PropertyValue(); loadProps[0].Name = "Hidden"; loadProps[0].Value = new Any(true); loadProps[1] = new PropertyValue(); loadProps[1].Name = "ReadOnly"; loadProps[1].Value = new Any(true); doc = componentLoader.loadComponentFromURL(strDoc, "_blank", 0, loadProps); if (doc != null) { var storable = doc.query<XStorable>(); PropertyValue pageRangeValue = new(); pageRangeValue.Name = "PageRange"; pageRangeValue.Value = new Any("2-3"); pageRangeValue.Handle = -1; List<PropertyValue> filterData = new(); filterData.Add(new PropertyValue( Name: "PageRange", Handle:-1 , Value: new Any("2-3"), State: PropertyState.DIRECT_VALUE)); //filterData.Add(new PropertyValue(Name: "Quality", Handle: -1, Value: new Any(100L), State: PropertyState.DIRECT_VALUE)); var props =filterData.ToArray(); ; PropertyValue[] saveProps = new PropertyValue[2]; saveProps[0] = new PropertyValue(); saveProps[0].Handle = -1; saveProps[0].Name = "FilterName"; saveProps[0].Value = new Any("writer_pdf_Export"); saveProps[1] = new PropertyValue(); saveProps[1].Handle = -1; saveProps[1].Name = "FilterData"; saveProps[1].Value = new Any(props.ToArray()); storable.storeToURL(strDoc +".pdf",saveProps); // here crash happens doc.dispose(); doc = null; } //desktop.terminate(); } catch(System.AccessViolationException ex) { Console.WriteLine(ex.Message); } catch (ExternalException ex) { Console.WriteLine(ex.Message); } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { doc?.dispose(); desktop?.terminate(); } [/CODE]
there was a typo in the code, here is the updated version, issue persist. [code] using com.sun.star.uno; using com.sun.star.lang; using com.sun.star.frame; using com.sun.star.util; using com.sun.star.beans; using com.sun.star.uno.native; using System.Runtime.InteropServices; using System.Transactions; using com.sun.star.ucb; //Console.WriteLine("Enter a key"); //var input = Console.ReadLine(); string strDoc; XDesktop desktop = null; XComponent doc = null; strDoc = @"file:///f:/test.docx"; // See https://aka.ms/new-console-template for more information try { XComponentContext context = NativeBootstrap.bootstrap(); XMultiComponentFactory factory = context.getServiceManager(); desktop = Desktop.create(context); XComponentLoader componentLoader = desktop.query<XComponentLoader>(); //com.sun.star.beans.PropertyValue[] szEmptyArgs = new com.sun.star.beans.PropertyValue[0]; PropertyValue[] loadProps = new PropertyValue[2]; loadProps[0] = new PropertyValue(); loadProps[0].Name = "Hidden"; loadProps[0].Value = new Any(true); loadProps[1] = new PropertyValue(); loadProps[1].Name = "ReadOnly"; loadProps[1].Value = new Any(true); doc = componentLoader.loadComponentFromURL(strDoc, "_blank", 0, loadProps); if (doc != null) { var storable = doc.query<XStorable>(); List<PropertyValue> filterData = new(); filterData.Add(new PropertyValue( Name: "PageRange", Handle:-1 , Value: new Any("2-3"), State: PropertyState.DIRECT_VALUE)); //filterData.Add(new PropertyValue(Name: "Quality", Handle: -1, Value: new Any(100L), State: PropertyState.DIRECT_VALUE)); var props =filterData.ToArray(); ; PropertyValue[] saveProps = new PropertyValue[2]; saveProps[0] = new PropertyValue(); saveProps[0].Handle = -1; saveProps[0].Name = "FilterName"; saveProps[0].Value = new Any("writer_pdf_Export"); saveProps[1] = new PropertyValue(); saveProps[1].Handle = -1; saveProps[1].Name = "FilterData"; saveProps[1].Value = new Any(props); storable.storeToURL(strDoc +".pdf",saveProps); doc.dispose(); doc = null; } //desktop.terminate(); } catch(System.AccessViolationException ex) { Console.WriteLine(ex.Message); } catch (ExternalException ex) { Console.WriteLine(ex.Message); } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { doc?.dispose(); desktop?.terminate(); } [/CODE]
Callstack from the crash within Visual Studio: > sal3.dll!00007ffdd98ec7f0() binaryurplo.dll!00007ffddc192c69() binaryurplo.dll!00007ffddc192780() binaryurplo.dll!00007ffddc192dad() binaryurplo.dll!00007ffddc192d8f() binaryurplo.dll!00007ffddc192d01() binaryurplo.dll!00007ffddc192780() binaryurplo.dll!00007ffddc192dad() binaryurplo.dll!00007ffddc192d8f() binaryurplo.dll!00007ffddc19b836() binaryurplo.dll!00007ffddc19a906() salhelper3MSC.dll!00007ffe56da4131() salhelper3MSC.dll!00007ffe56da4888() sal3.dll!00007ffdd9911068() ucrtbase.dll!00007ffecb9237b0() kernel32.dll!00007ffeccc8e8d7() ntdll.dll!00007ffecde514fc() Ausnahme ausgelöst bei 0x00007FFDD98EC7F0 (sal3.dll) in TestLibreOffice.exe: 0xC0000005: Zugriffsverletzung beim Lesen an Position 0x0000000000000000. Additional Hints, i am using NET 8.0 in 64bit Build on Windows11, but crash also occurs on Linux Ubuntu 24.04 64bit NET 8.0.