Using new dotnet binding throws following exception when getting XDesktop2 after connecting to LibreOffice: com.sun.star.uno.RuntimeException: could not map given type name com.sun.star.frame.XDesktop2 at /home/username/libregit/core/bridges/source/net_uno/net_base.cxx:230: at com.sun.star.uno.native.NetEnvironment.ThrowError(String pWhere, String pMessage) Steps to Reproduce: 1. Create a new .net 8 application 2. Add the LibreOffice.Bindings package from the LibreOffice SDK 3. Place the following code in the Main function: var unoUrl = "uno:socket,host=localhost,port=2083;urp;StarOffice.ServiceManager"; var localComponentContext = NativeBootstrap.defaultBootstrap_InitialComponentContext(); var urlResolver = UnoUrlResolver.create(localComponentContext); var resolvedObject = urlResolver.resolve(unoUrl) ?? throw new UnoWrapperException("Provided initial object name unknown at server side"); var defaultServerContext = resolvedObject.query<XPropertySet>() .getPropertyValue("DefaultContext") .cast<XComponentContext>(); var desktop = Desktop.create(defaultServerContext); var componentLoader = desktop.query<XComponentLoader>(); 4. Launch LibreOffice with: soffice "--accept=socket,host=localhost,port=2083;urp;" 5. Launch dotnet application 6. When calling "Desktop.create()" execution will fail with an error Actual Results: Desktop.create() throws an exception: com.sun.star.uno.RuntimeException: could not map given type name com.sun.star.frame.XDesktop2 at /home/username/libregit/core/bridges/source/net_uno/net_base.cxx:230: at com.sun.star.uno.native.NetEnvironment.ThrowError(String pWhere, String pMessage) Expected Results: Desktop.create() should return an XDesktop2 object without throwing an exception Reproducible: Always Additional Info: 1. The bug was filed after posting a question on Ask: https://ask.libreoffice.org/t/problem-with-dotnet-mapping-after-connect-to-libreoffice/122685 2. LibreOffice was built from source Version: 25.8.0.0.alpha0+ (X86_64) / LibreOffice Community Build ID: d572a56bea0a5ad01f485b365b2135c682c9f65f CPU threads: 4; OS: Linux 6.8; UI render: default; VCL: gtk3 Locale: en-US (en_US.UTF-8); UI: en-US Calc: threaded 3. OS: Ubuntu 22.04 4. Using the NativeBootstrap.bootstrap() function, which creates the LibreOffice process itself, works fine with the following code: var context = NativeBootstrap.bootstrap(); var desktop = Desktop.create(context); var componentLoader = desktop.query<XComponentLoader>();
Providing more information on reproduction. Used OS: Ubuntu 22.04 Steps: 1. Build LibreOffice from "d572a56bea0a5ad01f485b365b2135c682c9f65f" commit in master (follow the https://wiki.documentfoundation.org/Development/BuildingOnLinux) with "--with-dotnet=yes" option The next options was used in my build: --enable-odk --without-doxygen --disable-gtk4 --disable-firebird-sdbc --disable-postgresql-sdbc --disable-cve-tests --without-help --with-lang=en-US --with-dotnet=yes 2. Install dotnet 8 sdk and runtime: sudo apt-get update && \ sudo apt-get install -y dotnet-sdk-8.0 sudo apt-get update && \ sudo apt-get install -y aspnetcore-runtime-8.0 3. Create a console C# project: dotnet new console -n LOTest -f net8.0 --use-program-main true 4. Make directory for local nuget files: mkdir LocalPackages 5. Copy "LibreOffice.Bindings.0.1.0.nupkg" from builded LibreOffice sdk/dotnet directory to LocalPackages directory 6. Go to project dir: cd LOTest 7. Add package to project: dotnet add package "LibreOffice.Bindings" --version 0.1.0 -s ../LocalPackages 8. Open Program.cs file with your text editor 9. Add next using statements at start of the file: using com.sun.star.beans; using com.sun.star.bridge; using com.sun.star.connection; using com.sun.star.frame; using com.sun.star.lang; using com.sun.star.uno; 10. Copy code provided in bug description in 3rd reproduce step into Main(string[] args) method 11. Add the new class for exception after Program class end: class UnoWrapperException(string msg) : ApplicationException(msg) { } 12. Save and close Program.cs file 13. Launch LibreOffice from other console with: soffice "--accept=socket,host=localhost,port=2083;urp;" 14. Back to first console and run "./setsdkenv_unix" script from LibreOffice sdk directory 15. Build and run test dotnet program from LOTest directory: dotnet run 16. See the error