I'm trying to show a Print dialog, before printing in a WPF application. I'm using Microsoft sample code from this link
// Create the print dialog object and set options
PrintDialog pDialog = new PrintDialog();
pDialog.PageRangeSelection = PageRangeSelection.AllPages;
pDialog.UserPageRangeEnabled = true;
// Display the dialog. This returns true if the user presses the Print button.
Nullable<Boolean> print = pDialog.ShowDialog();
It crashes on the last line with the following exception:
PrintTicket provider failed to bind to printer. Win32 error: The printer name is invalid.
I tried searching for a solution, and the two that people suggest are installing Printer Server feature, and switching to Any CPU build, but neither of those worked in my case.