asp.net - C# Excel ActivePrinter Exception 0x800A03EC -


i cannot change active printer specific printer in excel asp.net web-service. service running under localsystem account. if call function shows list of printers:

system.drawing.printing.printersettings.installedprinters 

i list of installed in system printers:

"microsoft print pdf"

"microsoft xps document writer"

"hp universal printing pcl 6"

but if call function

excelapplication.activeprinter 

it returns -

unknown printer

when try set printer c# setting printer:

excelapplication.activeprinter = "microsoft xps document writer" 

or (i found port in register hive hkey_current_user\software\microsoft\windows nt\currentversion\devices)

excelapplication.activeprinter = "microsoft xps document writer on ne00:" 

it doesn't matter, exception 0x800a03ec.

finally, tried change default printer in system:

 [dllimport("winspool.drv",               charset = charset.auto,               setlasterror = true)]         [return: marshalas(unmanagedtype.bool)]         public static extern boolean setdefaultprinter(string name); 

it works fine, default printer in system has changed. in excel still "unknown printer"

also if open excel under account, in print settings can see default printer


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -