I have been getting sporadic reports of my application (compiled with Delphi 7) refusing to start on some PCs – it exited immediately with the Windows error message:
“….exe has encountered a problem and
needs to close. We are sorry for the
inconvenience”
My advice up until now has to always been to install a default printer (any printer – even a PDF printer) and the problem goes away. How can I fix the application? My program only access the PrinterDialog controls when the user pushes the Print button.
I received an email containing a bug report generated by MadExcept with the very helpful stacktrace:
The problem is caused by the fact I had set a number of properties of the TPrinterDialog at design time, such as the flag to print page numbers. When Delphi tried to create the form and set these properties on a PC with no printer, the error occurs.
The solution was to delete the old TPrinterDialog and replace it with a new default TPrinterDialog and set the properties at run time once a new printer was installed.