Click here to Skip to main content
12,951,823 members (93,752 online)
Rate this:
Please Sign up or sign in to vote.
See more:

I have been given the task of creating a WCF application hosted as a windows service to accept a Stream of data and then compile this into a file and print the file to a specified printer on our network. Most aspects of this application have now been completed however I am struggling with the printing method. Whenever I try and invoke the method for printer I am given the following error:
{"Settings to access printer '\\\\UKSPPS01\\UKSPPRN024' are not valid."}
I have looked online into this error and the only answers I can find is to have the printer installed locally, however this isn't really a viable option with this service. Has anybody got any better suggestions on how to overcome this, or how to print a file to a network printer not using the System.Drawing method I am using.
The code for printing is simply:
                streamToPrint = new StreamReader(filePath);
                        printFont = new Font("Arial", 10);
                        PrintDocument pd = new PrintDocument();
                        pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
                        pd.PrinterSettings.PrinterName = @"\\UKSPPS01\UKSPPRN024";
                        // Print the document.
Posted 8-Apr-13 23:58pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You will need to have a domain account under which the windows service runs in order to access the printer that is available on network.

Check this link[^]
SymbioticKaos 10-Apr-13 3:36am
Thank you for your post, this is a very good solution and I have tested against my application and it works fine. I also found another solution posted on Stack Overflow which can be found here
Rai Pawan 10-Apr-13 4:58am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,229
CHill60 3,490
Maciej Los 3,083
Jochen Arndt 1,975
ppolymorphe 1,880

Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 9 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100