Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/262.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 异常:字符串文件名太长(进程)_C#_Asp.net_Asp.net Mvc_Phantomjs - Fatal编程技术网

C# 异常:字符串文件名太长(进程)

C# 异常:字符串文件名太长(进程),c#,asp.net,asp.net-mvc,phantomjs,C#,Asp.net,Asp.net Mvc,Phantomjs,我使用下面的代码将参数传递给进程 ProcessStartInfo StartInfo = new ProcessStartInfo(); StartInfo.FileName = HttpContext.Current.Server.MapPath(@"\highcharts\phantomjs.exe"); StartInfo.Arguments = HttpContext.Current.Server.MapPath(@"\highcharts\highcharts-convert.

我使用下面的代码将参数传递给进程

 ProcessStartInfo StartInfo = new ProcessStartInfo();
 StartInfo.FileName = HttpContext.Current.Server.MapPath(@"\highcharts\phantomjs.exe");
 StartInfo.Arguments = HttpContext.Current.Server.MapPath(@"\highcharts\highcharts-convert.js");
 StartInfo.Arguments += @" -outfile " + path + @"\chart" + templateData[i].ReportTemplateChartId + ".png -width 800 -infile " + chartoptions1;
 StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
 StartInfo.CreateNoWindow = false;  
在chartoptions1中,我使用了一个JSON字符串,但它引发了一个异常,称字符串文件名太长,因此我创建了一个文本文件并尝试传递它,但没有生成图表图像。

从MSDN页面

在Windows Vista和Windows操作系统的早期版本上 系统中,将参数的长度添加到完整 进程的路径必须小于2080。在Windows 7及更高版本上 版本,则长度必须小于32699

你有没有检查StartInfo.Arguments的长度

另一方面,快速查看Github上的此页面

-infle:要转换的文件,假定它是JSON文件,脚本检查输入文件的扩展名是否为“.JSON”,或者 否则,它将假定它是一个svg文件

所以,-infle应该是一个文件,而不是JSON内容。我想您的ChartOptions 1相当大,因此您的错误消息字符串filename太长

Highcharts还可以检查填充路径256?的长度

正在运行的脚本应该至少具有对内嵌的读取权限,并且应该是可解析的;特别是如果没有指定工作目录,则必须使用infle添加完整路径,而不仅仅是文件名


要调试工作目录问题,只需使用c:\test

try with StartInfo.UseShellExecute=true等常量路径进行测试;还可以设置StartInfo.WorkingDirectory=HttpContext.Current.Server.MapPath@\highcharts;然后StartInfo.FileName=phantomjs.exe;默认情况下,StartInfo.UseShellExecute=true;我们需要设置StartInfo.WorkingDirectory=HttpContext.Current.Server.MapPath@\highcharts;当我们没有确切的路径时