系统格式异常+ PrintTicket

时间:2017-09-19 08:35:10

标签: c# xml printing formatexception

我有一个问题,我不明白如何解决它。特别是我在项目(C#,VB 2015)工作,包括订单,收据等,当我在调试模式下运行时,一切都很好。但是当我设置我的项目并运行我的应用程序时,出现了这个错误:

System.FormatException: PrintTicket XML is not well-formed. Root element is missing. ---> System.Xml.XmlException: 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)
   --- End of inner exception stack trace ---
   at MS.Internal.Printing.Configuration.InternalPrintTicket..ctor(Stream xmlStream)
   at System.Printing.PrintTicket..ctor(Stream xmlStream)
   at System.Printing.Interop.PrintTicketConverter.InternalConvertDevModeToPrintTicket(PTProviderBase provider, Byte[] devMode, PrintTicketScope scope)
   at System.Printing.PrintTicketManager.ConvertDevModeToPrintTicket(Byte[] devMode)
   at System.Printing.PrintQueue.get_UserPrintTicket()
   at Simple.Printing.PrintService.PrintOrder(IEnumerable`1 templates, Order order, Shift shift, IList`1 printingPosts, SimpleConfiguration configuration, Boolean showPrices, Invoice invoice, Boolean skipPosts, Int32 postPosition)
   at Simple.Domain.Services.OrderService.<>c__DisplayClass3c.<PrintOrder>b__39()

我无法打印我的订单。我的程序被粉碎的代码是:

var printer = dialog.PrintQueue;
var ticket = printer.UserPrintTicket ?? printer.DefaultPrintTicket;
var capabilities = printer.GetPrintCapabilities(ticket);
ticket.CopyCount = post.Copies > 0 ? post.Copies : ticket.CopyCount;

0 个答案:

没有答案