问题
Why I get the error when trying to do this function:
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
Error-code: -2147467259
Error: cant find the file specified
Now I'm trying two broken implementations:
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
来源:https://stackoverflow.com/questions/9565196/compileassemblyfromfile