CompileAssemblyFromFile

风流意气都作罢 提交于 2019-12-11 08:31:45

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!