question

RomanRodriguez-6200 avatar image
0 Votes"
RomanRodriguez-6200 asked LimitlessTechnology-2700 answered

LocalPrintServer instance throw exception in all its methods. Netcore 5 library class

I am creating an instance of the LocalPrint server
129286-1ff1725b-4709-4cde-a3e1-d9c02d82f087.jpeg


However, all its methods throw an exeption

129315-f1436cb3-04ee-4c3c-8fb5-a65295e3f9d8.png


I had to add the system.printing reference directly from the dll in visual studio 2019

129308-8df6d3b0-deba-4e39-a3a8-acb8b9b912c6.png

I am using netcore 5 , the method is in a class inside a class library project, and the method is invoked from a unit test project.

What do you think the problem is here?

Thanks in advance


dotnet-csharpwindows-server-print
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@RomanRodriguez-6200
Not a solution, just a few discoveries.
The version of System.Printing.dll added through IntelliSense should be 4.8.x.x.
It does not work for .Net 5, and the manually imported version is 5.0.x.x, it can make the code compile and pass, but there will be current problems.
This is not a simple code issue, I think it might be more appropriate for you to ask the question in the runtime GitHub repository.
By the way, if possible, please try to provide code snippets instead of pictures in the future. The pictures are very vague, and it is not conducive for us to quickly copy your code to reproduce your problem.

0 Votes 0 ·

1 Answer

LimitlessTechnology-2700 avatar image
0 Votes"
LimitlessTechnology-2700 answered

Hi there,

I would suggest you to look up the constructors as per the link and see if you have implemted them correctly in your code .

https://docs.microsoft.com/en-us/dotnet/api/system.printing.localprintserver?view=net-5.0
https://docs.microsoft.com/en-us/dotnet/api/system.printing.printserver.-ctor?view=net-5.0

Hope this Answers all your queries , if not please do repost back .
If an Answer is helpful, please click "Accept Answer" and upvote it : )

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.