一个打印pdf的小程序,在本机上运行一切正常,但是复制到其他机器上就会报错 ,错误信息如下
System.ComponentModel.Win32Exception: 没有应用程序与此操作的指定文件有关联。
在 System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startI
nfo)
在 System.Diagnostics.Process.Start()
在 Print.Print.PrintDoc(String filename) 位置 行39..源代码如下:
public void PrintDoc(string filename)
{
//检测当前打印的文档数,当超过2个,就开始等待
PrintDocument pd = new PrintDocument();
StringCollection sc = GetPrintJobsCollection(pd.PrinterSettings.PrinterName);
while (sc.Count > 2)
{
Thread.Sleep(1000);
sc = GetPrintJobsCollection(pd.PrinterSettings.PrinterName);
}
try
{
Process processInstance = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.UseShellExecute = true;
startInfo.Verb = "Print";
startInfo.CreateNoWindow = true;
startInfo.WindowStyle = ProcessWindowStyle.Minimized;
startInfo.FileName = filename;
processInstance.StartInfo = startInfo;
processInstance.Start();
}
catch(Exception e)
{
Console.Write(e.ToString());
}
}请高人解释是什么原因!
System.ComponentModel.Win32Exception: 没有应用程序与此操作的指定文件有关联。
在 System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startI
nfo)
在 System.Diagnostics.Process.Start()
在 Print.Print.PrintDoc(String filename) 位置 行39..源代码如下:
public void PrintDoc(string filename)
{
//检测当前打印的文档数,当超过2个,就开始等待
PrintDocument pd = new PrintDocument();
StringCollection sc = GetPrintJobsCollection(pd.PrinterSettings.PrinterName);
while (sc.Count > 2)
{
Thread.Sleep(1000);
sc = GetPrintJobsCollection(pd.PrinterSettings.PrinterName);
}
try
{
Process processInstance = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.UseShellExecute = true;
startInfo.Verb = "Print";
startInfo.CreateNoWindow = true;
startInfo.WindowStyle = ProcessWindowStyle.Minimized;
startInfo.FileName = filename;
processInstance.StartInfo = startInfo;
processInstance.Start();
}
catch(Exception e)
{
Console.Write(e.ToString());
}
}请高人解释是什么原因!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货