There is a need to mock System.Printing.PrintQueue for some test. Currently I'm getting this error when trying to create PrintQueue for presumably existing virtual printer (new PrintQueue(new PrintServer(), "Microsoft XPS Document Writer")):
System.Printing.PrintQueueException: PrintTicket provider failed to bind to printer. Win32 error: -2147467231
at MS.Internal.Printing.Configuration.PTProvider..ctor(String deviceName, Int32 maxVersion, Int32 clientVersion)
at MS.Internal.Printing.Configuration.PTProviderBase.Create(String deviceName, Int32 maxVersion, Int32 clientVersion)
at System.Printing.PrintTicketManager..ctor(String deviceName, Int32 clientPrintSchemaVersion)
at System.Printing.PrintQueue.GetPrintCapabilities()
Note the error is not about missing printer.
I can shim PrintTicket that is on the top of stack using Fakes, but it's absolutely not clear which method is throwing. And PrintQueue is not a managed class (resides in PrintQueue.cpp). Any ideas?
edit
Googled around a bit, still no luck getting around this issue:
https://connect.microsoft.com/VisualStudio/feedback/details/690455/printqueue-getprintcapabilities-throws-when-incorrect-driver-is-configured-for-printer-on-print-server
http://www.infragistics.com/community/forums/t/50736.aspx
http://petterisbetter.com/michael/index.php/2008/09/29/printticket-provider-failed-to-retrieve-