Trouble using UNOIDL library in C# on Windows 11: uno.Any[] argsArray = new uno.Any[] { new uno.Any(context)};

Greetings everyone again, i have another problem linked to UNOIDL library and C#.
I wrote this function

public static object[] Load_LO_calc_file_complete(string filePath, PropertyValue[] loadProps)
          XComponentContext context = uno.util.Bootstrap.bootstrap();
          XMultiComponentFactory xMSF = context.getServiceManager();
          uno.Any[] argsArray = new uno.Any[] { new uno.Any(context)};
          XDesktop desktop = (XDesktop)xMSF.createInstanceWithArgumentsAndContext("", argsArray, context);
          XComponentLoader componentLoader = (XComponentLoader)desktop;
           XComponent calcDoc = componentLoader.loadComponentFromURL("file:///" + filePath, "_blank", 0, loadProps);
          XModel xModel = (XModel)calcDoc; // Ottieni XModel dal documento
          XSpreadsheetDocument xSpreadsheetDocument = (XSpreadsheetDocument)calcDoc;
          XSpreadsheets spreadsheets = xSpreadsheetDocument.getSheets();
          XIndexAccess sheetsIndex = (XIndexAccess)spreadsheets;
          XSpreadsheet currentSheet = (XSpreadsheet)sheetsIndex.getByIndex(0).Value;
          string activeSheetName = Get_active_sSheet_name(calcDoc);
          XPrintable printDocument = (XPrintable)calcDoc;
          // Prepare objects for return
          object[] references = {
          return references;

But I’ve some problems with this instruction (context):
uno.Any[] argsArray = new uno.Any[] { new uno.Any(context)};
the error:
Error CS1503 Argument 1: cannot convert from ‘’ to ‘char’
I don’t understand the error and i don’t know what to do . Does anyone smarter than me have any ideas?
Thank you in advance :blush:

[erAck: edited to format code as code, see This is the guide - How to use the Ask site? - #6 by erAck]

I apologize for not having followed the rules; I’m a novice! :grimacing:I’m very grateful to you for the correction. :blush:

1st: Replace

uno.Any[] argsArray = new uno.Any[] { new uno.Any(context)};


uno.Any[] argsArray = new uno.Any[] { new uno.Any(typeof(XComponentContext), context)};

This will remove the compilation error.

2nd: In

xMSF.createInstanceWithArgumentsAndContext("", argsArray, context);

it does not really make sense to put the context into the argsArray. The context is already passed as the third parameter. I do not believe that arguments are needed to instantiate Desktop. It works also when argsArray is null

3rd: In general, if you are not yet familiar with the uno object model I recommend to get something working in LOBasic, and then translate to c#. The former is relatively well documented and you find many examples and much help in the forum. The latter is poorly documented and not very well supported in the forum

Good luck,


P.S.: And sometimes RTFM…,%20java.lang.Object)