I am trying to print from a Windows Docker Container where I have a .NET 6 ASP.NET Api hosted. Here is my code:
private readonly PrintDocument _document;
// Some code here
public async Task PrintAsync(PrintInput input)
{
// Some code here
_document.PrinterSettings.PrinterName = "\\server_name\shared_printer_name";
// Some code here
_document.PrintPage += _document_PrintPage;
_document.Print();
}
My docker container is running the following images:
FROM mcr.microsoft.com/windows/servercore:ltsc2019 AS base
...
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
...
ENTRYPOINT ["dotnet", "App.Web.Host.dll"]
The error message that I am getting is:
The RPC server is unavailable
The host is a Windows 2019 Server and has the Service Spooler Running. The Windows container has not have a Spooler Service Running.
I was having the message:
Windows cannot connect to the printer, Operation failed with error 0x00000bcb
Then I tried: Fix Network Printer error, but it didn't help.
Also, I had tried this one: Print Spooler in Windows Containers. No success as well.
I am wondering if it is not possible to use: PrintDocument inside an application running under a Windows Docker Container. What do you guys think?