2013-02-27 119 views
0

我使用如下代码:运行从代码异常perl脚本

static void Main(string[] args) 
    { 
     ProcessStartInfo perlStartInfo = new ProcessStartInfo(@"C:\strawberry\perl\bin\perl.exe"); 
     perlStartInfo.Arguments = "c:\\ebm\\parse_ebm_log.pl"; 
     perlStartInfo.UseShellExecute = false; 
     perlStartInfo.RedirectStandardOutput = true; 
     perlStartInfo.RedirectStandardError = true; 
     perlStartInfo.CreateNoWindow = false; 

     Process perl = new Process(); 
     perl.StartInfo = perlStartInfo; 
     perl.Start(); 
     perl.WaitForExit(); 
     string output = perl.StandardOutput.ReadToEnd(); 
    } 

现在我有这样的例外,当我看着perl.MainModule: MainModule =“perl.MainModule”扔类型的异常

'System.ComponentModel.Win32Exception' 基{System.SystemException} = { “一个ReadProcessMemory或WriteProcessMemory的请求的仅一部分 完成”}

目标构建支持x64由于同一perl.MainModule一异常时就表示无法运行X32程序的x64(类似的东西)

+0

Perl是否独自工作(不从.Net中调用)? – m0skit0 2013-02-27 15:27:42

+0

什么是'C:\草莓\ perl \ bin \ perl.exe -V:archname'(大写'V') – ikegami 2013-02-27 16:44:51

回答

1

尝试在PATH环境添加的Perl(打开一个新的窗口之后,壳牌)沿与下面的变化

ProcessStartInfo perlStartInfo = new ProcessStartInfo() 
perlStartInfo.FileName= "perl.exe" 
perlStartInfo.UseShellExecute = true 
+0

嗨,PATH已经在那里了。我改变了代码,但我有同样的问题。事情是我需要'perlStartInfo.UseShellExecute = true',因为我将脚本输出重定向到C#中的字符串。我也尝试过对你的代码进行修改。 – JohnDoeKazama 2013-02-28 08:51:30

+0

我写了另一个简单的脚本与打印功能,现在它的工作,所以内存问题可能是关于perl脚本。等待新的脚本,如果再次发生相同的问题将发布它。谢谢。 – JohnDoeKazama 2013-02-28 10:59:47