New PrintServer object fails, "printer name is invalid"

509 views Asked by At

I'm migrating a working ASP.NET web application from WS2008R2 to WS2016, but the same happens on WS2012R2. It fails when executing:

new System.Printing.PrintServer(@"\\printserver");

It throws:

System.Exception: An exception occurred while creating the PrintServer object. Win32 error: The printer name is invalid.

printserver is not an alias but a hostname. It loads correctly on Windows Explorer. The same line works fine on a regular Console Application when compiling under the same .NET 4.5.2, and also in PowerShell when loading the System.Printing.dll. The GAC shows the right assemblies, and I've also added them manually just in case.

I've set the same application pool configuration settings from the working WS2008 (disabled 32-bit applications and Classic mode), but I've tried different combinations in any case. The application pool runs under the same domain service account on both old and new.

As some user also suggested, I've installed the Print and Document services role, even though the old server doesn't have it, but to no avail.

I'm out of ideas, any kind of help would be greatly appreciated. Thanks!

1

There are 1 answers

0
Armaggedon On

Not really a solution... But I "fixed" this by changing the path of the website in IIS manager back and forth a couple of times. Yes, after a year of trying all I could think of on several servers.

Anyway, not sure what exactly unblocked the situation, but it works for me.