为什么我在尝试执行此功能时出现错误:
let compile_file path use_asms output =
use pro = new FSharpCodeProvider()
let opt = CompilerParameters(use_asms, output)
let res = pro.CompileAssemblyFromFile(opt, path) // <-- Error
if res.Errors.Count = 0
then Some(FileInfo(res.PathToAssembly))
else None
错误代码:-2147467259
错误:无法找到指定的文件
现在我正在尝试两个破解的实现:
type System.CodeDom.Compiler.ICodeCompiler with
member this.CompileAssemblyFromFile
(options:CompilerParameters,fileName:string) : CompilerResults =
this.CompileAssemblyFromFileBatch(options, [|fileName|])
let compile_file str assemblies output =
let pro = new System.CodeDom.Compiler.CodeCompiler()
let opt = CompilerParameters(assemblies, output)
let res = pro.CompileAssemblyFromFile(opt, str)
if res.Errors.Count = 0 then
Some(FileInfo(res.PathToAssembly))
else None
let compile_file2 path use_asms output =
use pro = new FSharpCodeProvider()
let opt = CompilerParameters(use_asms, output)
let res = pro.CompileAssemblyFromFile(opt, path)
if res.Errors.Count = 0
then Some(FileInfo(res.PathToAssembly))
else None