I have a problem that I dont understand how to fix it. Specially I work at project (C#,VB 2015) with orders, receipts etc and when I run at debug mode everything works great. But when I made a setup of my project and run my application this error appeared:
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()
and I cant print my order. The code where my program is crushed is that :
var printer = dialog.PrintQueue;
var ticket = printer.UserPrintTicket ?? printer.DefaultPrintTicket;
var capabilities = printer.GetPrintCapabilities(ticket);
ticket.CopyCount = post.Copies > 0 ? post.Copies : ticket.CopyCount;