Yesterday when the web side called someone else to write word processing DLL, there was a
' The invocation of the constructor on type ' System.Windows.Documents.DocumentReference ' that matches the specified binding Constraints threw an exception. ' Line number ' 2 ' and line position ' 21 '.
Problem, this question I wrote the example program is no problem (CS side), after others ' guidance, found in the place where the exception was thrown innerexception is the STA problem, this specifically did not keep the information.
According to InnerException's tip, the XPS object and the method in it were found to be STA, but the ASPX page was the MTA, and after a few twists and turns to find someone who encountered the same problem: http://stackoverflow.com/questions/ 24058070/how-to-read-a-xps-file-in-c-sharp-using-asp-net
The problem is really the same, and then follow the link provided inside (the second one) to add
<%@ page language= "C #" aspcompat= "true"%>
I've tried it, it's completely useless. HttpHandler himself not familiar, so wrote a thread to call the output of the XPS Document method, and then successfully completed, the code example is as follows:
....//Call place System.Threading.Thread Thread = new System.Threading.Thread (New System.threadi Ng. Parameterizedthreadstart (Threadmethod)); Thread. Start (value); Thread. Join ();//wait for the end//....
thread function private void Threadmethod (object parameter) {//This is the code that is written for XPS processing}
Summary: The concept of STA, MTA needs to be familiar, other threads, thread synchronization, threads pool and other concepts need to be consolidated a bit more
This article is from the "more efforts, the more Fortunate" blog, please be sure to keep this source http://actor.blog.51cto.com/1764681/1594057
An exception occurred when ASP. NET called XPS Object Getfixeddocumentsequence