【发布时间】:2012-05-22 08:22:03
【问题描述】:
我生成一个新进程并让它像这样调用 F# 编译器:
var exeName = args[0];
var commandLine = args[1];
using (var process = new Process())
{
process.StartInfo = new ProcessStartInfo(exeName, commandLine);
process.StartInfo.UseShellExecute = true;
process.StartInfo.LoadUserProfile = true;
process.Start();
}
我传入的参数是 fsc.exe 的路径以及我要构建的代码的参数。
结果异常:
Unhandled Exception: System.ArgumentException: chop_extension
at Internal.Utilities.Filename.chop_extension(String s)
at Microsoft.FSharp.Compiler.Build.TcConfigBuilder.DecideNames(FSharpList`1 sourceFiles)
at Microsoft.FSharp.Compiler.Driver.main1(String[] argv)
at Microsoft.FSharp.Compiler.ErrorLogger.ErrorLoggerExtensions.ReraiseIfWatsonable(Exception exn)
at Microsoft.FSharp.Compiler.ErrorLogger.ErrorLoggerExtensions.ErrorLogger.ErrorRecovery(ErrorLogger x, Exception exn, range m)
at Microsoft.FSharp.Compiler.ErrorLogger.errorRecovery(Exception exn, range m)
at Microsoft.FSharp.Compiler.Driver.main1(String[] argv)
at Microsoft.FSharp.Compiler.Driver.main(String[] argv)
at Microsoft.FSharp.Compiler.CommandLineMain.main(String[] argv)
at Microsoft.FSharp.Compiler.ErrorLogger.ErrorLoggerExtensions.ReraiseIfWatsonable(Exception exn)
at Microsoft.FSharp.Compiler.ErrorLogger.ErrorLoggerExtensions.ErrorLogger.ErrorRecovery(ErrorLogger x, Exception exn, range m)
at Microsoft.FSharp.Compiler.ErrorLogger.errorRecovery(Exception exn, range m)
at Microsoft.FSharp.Compiler.CommandLineMain.main(String[] argv)
但是,当我从命令提示符运行相同的命令和参数时,它编译时没有错误
知道是什么原因造成的吗?
【问题讨论】:
-
你使用的论据是什么?可能是输入字符串格式错误。
-
您是从 C# 代码调用 fsc exe 吗?这就是第一个代码片段的样子,我只想确认我的假设。我同意 Pad——向我们展示 exeName 和 commandLine 的值。