2


I have C# program, which sends uses PrintTo verb when spawning process to print file to specified printer. However, when I try to print .pdf or html file, it says

Unhandled Exception: System.ComponentModel.Win32Exception: No application is associated with the specified file for this operation
   at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)

I have PDF Complete installed and double clicking on pdf file opens it correctly. Same things happens with .html file (I have Mozilla Firefox as default browser).

EDIT:

My code:

ProcessStartInfo info = new ProcessStartInfo(args[0]);
info.Arguments = "\"" + args[1] + "\"";
info.CreateNoWindow = true;
info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
info.UseShellExecute = true;
info.Verb = "PrintTo";
Process.Start(info);

And command line call: >myapp.exe D:\Temp\test.pdf "PDF Complete"

For example >myapp.exe D:\Temp\test.txt "PDF Complete" works

12
  • 1
    Then maybe startInfo is wrong? Commented Sep 19, 2014 at 20:22
  • @VladL I added code as well as information, how am I calling the application. Commented Sep 19, 2014 at 20:37
  • What about launching from command prompt just the file... ie cd D:\Temp and then D:\Temp\test.pdf (enter)- does this launch the pdf correctly? Commented Sep 19, 2014 at 20:42
  • Is D:\Temp\test.pdf a real path or maybe the real one has whitespaces? Commented Sep 19, 2014 at 20:54
  • @alykins Yes, there is no problem doing that. It opens in PDF Complete. start test.pdf also works. Commented Sep 19, 2014 at 20:55

2 Answers 2

2

For anyone still interested. PrintTo verbs are not quite supported by neither PDF Complete nor Firefox

Sign up to request clarification or add additional context in comments.

Comments

0

I had a similar error on a method that was printing a .pdf. Everything worked great until my computer crashed due to an array failure on the hdd controller.

After I rebuilt the computer I went back to finishing this code portion. However, it didn't work - I got the error listed in the OP above.

After a bit of inspection and checking out this thread I discovered that Windows 10 was using Edge for .pdf files. I installed Adobe Reader and viola~! No more error and the Process.Start() printed the file.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.