An exception occurred when ASP. NET called XPS Object Getfixeddocumentsequence

Source: Internet
Author: User


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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.