Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Process.Start(/* path to pdf */) doesn't work with Adobe Reader on Windows 8

I'm able to create PDFs in my C#/WPF application and run them with the following:

Process.Start(_pathToPDFFile);

This works with Adobe Acrobat, but not with Adobe Reader. When Adobe Reader is installed, Process.Start() does nothing unless the Reader process is already running in the Task Manager.

How can I get Adobe Reader to show the PDF when I attempt to start a PDF?

like image 638
DaveDev Avatar asked May 21 '14 08:05

DaveDev


2 Answers

Maybe try something like this? I tried you code on Windows 8 with Adobe Reader 11 and it seems to work fine for me. Maybe something else is wrong on the machine in question?

var process = new Process();
process.StartInfo = new ProcessStartInfo(@"Path to your PDF.pdf");
process.StartInfo.CreateNoWindow = true;
process.StartInfo.UseShellExecute = true;
process.Start();
like image 145
Mo Patel Avatar answered Nov 09 '22 14:11

Mo Patel


In our case, the problem was only reproducible when starting the application from Visual Studio - starting the .exe directly works as expected.

After some debugging, it turned out that Visual Studio was set to always run as administrator, which causes the issue. Turning this off (which is hard enough itself) fixes the problem.

Still not sure why this happens, though.

like image 20
Borislav Ivanov Avatar answered Nov 09 '22 16:11

Borislav Ivanov