Printer.executequeryandwait() Causing Application To Crash
Most every time I call upon the Printer.ExecuteQueryAndWait() more than once it causes my application to crash due to heap stack data corruption.
I created a simple WPF .NET 4.5 application to help isolate the problem. The xaml is not included.
After testing, it seems the application only crashes if I execute the query more than once during the lifespan of the application.
Edit: It also crashes after being called once, if the application processes other data through the heap afterwards.
I've also used the other overload of the method that specifies a timeout and have adjusted that timeout from 1000 to 10000 ms with no differing results.
I'm using the ~HL command to retrieve the RFID tag IDs that were printed and encoded to.
Notes:
- Printer is correctly installed and successfully returns results from the same command using the printer's "Send Printer Command" in the 'Tool' tab of the properties window.
- Upon clicking the application's 'Send Command' button, the same results as above are shown in the text box.
- Upon application crashing, the results are displayed before the application becomes unresponsive.
- Printer.ExecuteQuery() method causes the same crash.
- Edit: Ran the program on a different machine and the same crash occurs
Software details:
- Windows 7 64bit Professional Edition SP1
- Microsoft Visual Studio 2013
- BarTender Automation Edition v.10.1 SR4
- Seagull.BarTender.Print.dll v.10.1.4.1
Please let me know if I'm utilizing this method incorrectly or if I am missing a function to use in conjunction with this.
Here's the code for it:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using Seagull.BarTender.Print; namespace PrinterCommandTest { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : System.Windows.Window { private const string RFID_PRINTER = "Zebra R110Xi4 (203 dpi)"; Printer myPrinter = null; public MainWindow() { InitializeComponent(); SetupPrinter(); } private void SetupPrinter() { Printers printers = new Printers(); foreach (Printer printer in printers) { if (printer.PrinterModel == RFID_PRINTER) { myPrinter = printer; break; } } } private void btnSendCommand_Click(object sender, RoutedEventArgs e) { btnSendCommand.IsEnabled = false; PrinterQueryCommand command = new PrinterQueryCommand("~HL"); PrinterQueryResult result = myPrinter.ExecuteQueryAndWait(command); if (result.Succeeded) txtResults.Text = result.ResponseText; btnSendCommand.IsEnabled = true; } private void btnReset_Click(object sender, RoutedEventArgs e) { txtResults.Text = ""; } } }
Windows Crash message:
Problem signature:Problem Event Name: APPCRASHApplication Name: PrinterCommandTest.exeApplication Version: 1.0.0.0Application Timestamp: 54cfd028Fault Module Name: StackHash_5796Fault Module Version: 6.1.7601.18229Fault Module Timestamp: 51fb1072Exception Code: c0000374Exception Offset: 000ce753OS Version: 6.1.7601.2.1.0.256.48Locale ID: 1033Additional Information 1: 5796Additional Information 2: 5796cba8b2c08c62ce93772a94d36757Additional Information 3: 2796Additional Information 4: 2796689145e811c0957279acf90e5217
Message that Visual Studio 2013 gives when using Debug mode.
Unhandled exception at 0x7797E753 (ntdll.dll) in PrinterCommandTest.exe: 0xC0000374: A heap has been corrupted (parameters: 0x779B4270).
-
- How is the printer connected to the PC where BarTender is running? Directly via a local port (USB...)? Via the internal IP address of the printer as a TCP/IP port? As a shared network printer?
- Is Printer Maestro service both installed on the PC where the printer driver has been installed and the PC where BarTender is running?
- What printer driver and version have you installed for the printer?
- Open the printer driver properties for your Zebra printer, now access the "Tools" tab and click on "Driver Options > Network Settings". Attach a screenshot of this dialog using the "More Reply Options" button.
0
Please sign in to leave a comment.
Comments
1 comment