I am out of idea why this is NOT working:
PrintServer printServer = new PrintServer("\\\\servername");
I am having issue with the PrintServer initialization. The above mentioned exception keep appearing even the printerServer path provided is a valid path. This is being said so as I am able to enumerate all the printers using printerServer.GetPrintQueues and foreach the printQueue to get the corresponding HostingPrintServer name.
EnumeratedPrintQueueTypes[] queueTypesArray = new EnumeratedPrintQueueTypes[]
{
EnumeratedPrintQueueTypes.Connections,
EnumeratedPrintQueueTypes.Local,
};
PrintQueueIndexedProperty[] indexPropertyArray = new PrintQueueIndexedProperty[]
{
PrintQueueIndexedProperty.Name
};
PrintServer printServer = new PrintServer();
PrintQueueCollection queueCollection = printServer.GetPrintQueues(indexPropertyArray, queueTypesArray);
foreach (PrintQueue pq in queueCollection)
{
if (pq.FullName == printerName)
{
this.printServerName = pq.HostingPrintServer.Name;
this.printerName = pq.Name;
}
}
I have also tried using the way this post suggested to get the DNS hostEntry but without any luck.
PrintServerException - "...name is invalid" even though I can access the path from windows
For your information, I am using Visual Studio 2010 running on Windows XP with two network printers connected. The printers are able to perform printing without any issue using PrintDocument and the printers are displayed on the PrintDialog as well.
Does anyone faced this issue before? If yes, may I know how do you resolve the issue?
Million thanks in advance.
EDIT:
Just tested with another "real" server printer, the above mentioned method is working fine. It is believed that Novell iPrint service which I am not sure how is the behaviour of it causing the issue. If anyone know more about the way to access Novell iPrint print server using C#, please feel free to share. I am currently still searching for the solution.