Salve a tutti.
Ho fatto un servizio che ciclicamente chiede l'elenco delle stampanti per poi fare dei controlli.
Il codice è abbastanza semplice:
// Leggo tutte le stampanti
PrintServer printServer = new PrintServer();
foreach (PrintQueue pq in printServer.GetPrintQueues())
{
...
}
Di suo il servizio funziona bene... Finchè, ad un certo punto, l'istruzione di creazione del PrintServer (PrintServer = new PrintServer) esce col seguente errore:
System.ComponentModel.Win32Exception: The system cannot find the file specified
at MS.Win32.UnsafeNativeMethods.RegisterClassEx(WNDCLASSEX_D wc_d)
at MS.Win32.HwndWrapper..ctor(Int32 classStyle, Int32 style, Int32 exStyle, Int32 x, Int32 y, Int32 width, Int32 height, String name, IntPtr parent, HwndWrapperHook[] hooks)
at MS.Win32.MessageOnlyHwndWrapper..ctor()
at System.Windows.Threading.Dispatcher..ctor()
at System.Windows.Threading.Dispatcher.get_CurrentDispatcher()
at System.Windows.Threading.DispatcherObject..ctor()
at System.Printing.PrintServer.Initialize(String path, String[] propertiesFilter, PrinterDefaults printerDefaults)
at System.Printing.PrintServer..ctor()
Qualcuno mi sa dire il perchè?
Ora provo ad usare il "vecchio metodo" (mediante ManagementObject), però non mi dispiaceva usare la nuova classe... Molto più comoda...
Grazie mille
Modificato da JoeRuspante il 04 febbraio 2010 09.31 -