Hi Javier,
Was this DLL successfully imported into FrameworX?
You can check this by going to Scripts / References, importing the DLL, and then clicking “Verify References.”
If it was imported successfully, could you send the error message you encountered when running the code?
Good day, yes, I attach an image where you can see that if I load the dll correctly.
What we are looking for is that this function is executed by the server and not the clients, I have observed that if I run the function from a display if it runs, but when I try to put it in a Task(ServerStartup) we mark the error, which I shared with you.
The “The calling thread must be STA, because many UI elements require this” error indicates that the called function is using a UI framework such as WPF or Windows Forms, where certain objects (like dialogs, message boxes, or some COM components) require the thread to be STA (Single-Threaded Apartment)
In general, UI interactions should not be handled in server-side functions, as this is considered poor programming practice. Server-side tasks are typically designed to run in a non-UI (background) context.
However, if it’s absolutely necessary to invoke a UI-related method from a server-side context (not recommended), you can work around the error using an STA thread like this:
System.Threading.Thread staThread = new System.Threading.Thread(() =>
{
//Call the UI-related method here
YourMethodThatNeedsSTA();
});
staThread.SetApartmentState(System.Threading.ApartmentState.STA);
staThread.Start();
staThread.Join();
That said, this is a long shot — I can’t say for sure whether it will work in your case because I don’t have access to the specific DLL or component you’re using. If this workaround doesn’t resolve the issue, I recommend reaching out to FrameworX support, as they’ll be able to provide a more specialized assistance.