I am getting this error with inner exception "The calling thread must be STA because many UI components require this."
System.Windows.Markup.XamlParseException: ''The invocation of the constructor on type 'System.Windows.Documents.DocumentReference' that matches the specified binding constraints threw an exception.' Line number '1' and line position '130'.'
This is not a WPF application. It is a winforms client application which connects to a windows service that always runs in the background. The windows service calls a class libray. This code resides in the class libray. I am thinking this windows service is multi-threaded because of the nature of a windows service. So this error? How do I fix it is the question?
I have the same code in a standalone test application where there are no services nothing. Just a simple winforms where in Form_load I do the processing. That works fine. Only when I access this code from the original application this error occurs
var path = @"C:\Filess\2020-5-14\username2020514232518460.xps";
using (XpsDocument xpsDoc = new XpsDocument(path, FileAccess.Read))
{
FixedDocumentSequence docSeq = xpsDoc.GetFixedDocumentSequence(); //error occurs here
// return //SaveDocumentPagesToImages(docSeq.DocumentPaginator.Source//, tiffsavePath);
}