Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File not found when printing from web service #38

Open
JeffSE97062 opened this issue May 20, 2022 · 10 comments
Open

File not found when printing from web service #38

JeffSE97062 opened this issue May 20, 2022 · 10 comments
Assignees

Comments

@JeffSE97062
Copy link

JeffSE97062 commented May 20, 2022

I am trying to print from a .NET web service. The exception being thrown is "The system cannot find the file specified". I assume that means the pdf itself, but the file does exist. System.IO.File.Exists(mypdffile) run during debug returns true. The service is running in Visual Studio 2013 framework 4.7 on my local box on which I am an admin. If I use the same code in a console app it works fine. The PDFtoPrinter.dll and PDFtoPrinter.exe are in the project's bin folder.

var wrapper = new PDFtoPrinterPrinter();
                await wrapper
                    .Print(new PrintingOptions(
                        printer, filePath)
                        );

Update: I noticed a closed post where someone was having the same issue but in a WPF project. A recommendation was to install using Nuget rather than manually (even though that works in a console app). Unfortunately, the install fails and is rolled back:

image

Thanks for any help.

@svishnevsky svishnevsky self-assigned this May 27, 2022
@svishnevsky
Copy link
Owner

Hi @JeffSE97062

Could you please provide your ".csproj" file? This will help to investigate the issue.

@JeffSE97062
Copy link
Author

EmailService.zip
Hi @svishnevsky, file is attached.

@svishnevsky
Copy link
Owner

Hi @JeffSE97062
Could you please try version 1.3.1 of the package and let me know if it works? (https://www.nuget.org/packages/PDFtoPrinter/1.3.2)

As I see the issue is in https://github.com/svishnevsky/PDFtoPrinter/blob/master/PDFtoPrinter/build/PDFtoPrinter.targets
image
However it is required for other projects. I still trying different conditions to do not break existing platforms support. Will keep you updated if I'll find an options to support all cases.

@JeffSE97062
Copy link
Author

Hi @svishnevsky, your last message said to try 1.3.1 but your link is to 1.3.2. Can you please clarify?

@svishnevsky
Copy link
Owner

Hi @JeffSE97062
Sorry for confusion. Please try 1.3.1 https://www.nuget.org/packages/PDFtoPrinter/1.3.1

@JeffSE97062
Copy link
Author

JeffSE97062 commented May 30, 2022

@svishnevsky 1.3.1 installed without errors, but the project wouldn't build because it couldn't find the file "...packages\PDFtoPrinter.1.3.1\buildPDF-XChange Viewer Settings.dat". I copied the file (not sure if version matters??) into the expected folder and the project built successfully, but I received the same error: "The system cannot find the file specified".

@TinaKopp
Copy link

TinaKopp commented Jun 2, 2022

I believe that the file not found is PDFtoPrinter.exe on Process Start. I am getting this error, even with PDFtoPrinter.exe and .dll (as well as PDF-X-Change Viewer Settings.dat) in the bin folder.

@JeffSE97062
Copy link
Author

JeffSE97062 commented Jun 3, 2022

That file is in my bin as well as the dll. Identical setup in a console app works, just not in a web service. Seems to work in a Windows service as well.

@svishnevsky
Copy link
Owner

@JeffSE97062 sorry for the long response, it is not easy to reproduce this issue. What approach do you use to build a windows service? I use in person Topshelf and it works fine.

@JeffSE97062
Copy link
Author

JeffSE97062 commented Jun 6, 2022

@svishnevsky I am actually getting the file-not-found error in a .NET web (not Windows) service. I am using VS 2013 .NET 4.5 with the 1.3.1 Nuget package installed. Solution compiles OK.

svishnevsky pushed a commit that referenced this issue Jun 13, 2022
This was unblocked by adding "m" to the file name as it is hardcoded in the original util
svishnevsky added a commit that referenced this issue Jun 13, 2022
#38 allow to run multiple instances of PdfToPrinter.exe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants