Hello @Marta,
you can find here a post about using C#, VB.NET, JScript or PowerShell code as UiPath Studio actvitiy. With the Run PowerShell or Run PowerShell String activities you have the possibility to decide to use single-threaded apartment (STA) or multi-threaded apartment (MTA).
Let us know your results.
Best regards
Stefan