System.Windows.Controls.PrintDialog throws exception when I run under a different Windows Account

253 views Asked by At

I have this error that I can't fix and I reformatted this question after I got some testing done.

I have a code that works in my application if I am running the program with the same user I am logged as to windows:

PrintDialog printDialog = new PrintDialog();
printDialog.PrintDocument(((IDocumentPaginatorSource)flowDocument).DocumentPaginator,description);

However, when I try to run my application with a different account (for example elevate as an administrator or Run By Different User), my application crashes on this part of the code.

I get the following exception:

PrintTicket XML is not well-formed. Root element is missing.Root element is missing. at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.ParseDocumentContent() at System.Xml.XmlTextReaderImpl.Read() at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace) at System.Xml.XmlDocument.Load(XmlReader reader) at System.Xml.XmlDocument.Load(Stream inStream) at MS.Internal.Printing.Configuration.InternalPrintTicket..ctor(Stream xmlStream)

I am not using XML files ( I think it's a break in the internal code not my code).

The object PrintDialog would have errors too in it as shown: errors

These (X)s show the moment I initiate the object ( new PrintDialog())

Also, I noticed that this exception wont happen if I build my program with Platform Target Any CPU or x64. However, I have to make i built as x86 for DLLS that I have.

What could be the issue?

0

There are 0 answers