引用外部程序集失败

时间:2016-09-29 19:53:35

标签: f# azure-functions

我无法引用私人装配工作。我已按照文档进行操作,但仍然失败并显示错误消息:

2016-09-29T19:43:08.615 startup(2,1): error FS82: Could not resolve this reference. Could not locate the assembly "Backend.dll". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. (Code=MSB3245)

这是run.fsx文件:

#r "Backend.dll"

open System
open System.IO
open System.Net
open System.Net.Http.Headers
open System.Collections.Generic
open CoP

let createResponse json =
    let responseJson = Request.handleJson json
    let response = new HttpResponseMessage()
    response.Content <- new StringContent(responseJson)
    response.StatusCode <- HttpStatusCode.OK
    response.Content.Headers.ContentType <- MediaTypeHeaderValue("application/json")
    response

let Run (req: HttpRequestMessage) =
    async {
        let! json = req.Content.ReadAsStringAsync()
        return createResponse json
    } |> Async.StartAsTask

我还将Backend.dll放在与该函数相同的文件夹内的bin文件夹中。

azure function folder structure

我错过了什么?

2 个答案:

答案 0 :(得分:4)

看起来您在Azure Functions F#实现中遇到了私有程序集解析的错误。 我已打开此问题进行跟踪,并将在下一版本中包含修复程序: https://github.com/Azure/azure-webjobs-sdk-script/issues/733

与此同时,您应该能够使用以下方式引用您的私人程序集:

#r "bin/Backend.dll"

希望这有帮助!

答案 1 :(得分:3)

如果这只是关于.fsx脚本的问题,我说你错过了告诉FSI在哪里寻找要引用的dll的部分:

#I "bin"
#r "BackEnd.dll"

Azure是否可以将.\bin文件夹放在#r指令可以访问的上下文中?