2
我正在使用VS代碼和Ionide在Mac上編輯F#Azure函數文件。Mono的System.Net.Http支持createResponse嗎?
下面是我的小測試功能:
#if !COMPILED
#I "../packages/Microsoft.Azure.WebJobs/lib/net45/"
#r "Microsoft.Azure.WebJobs.Host.dll"
#endif
#r "System.Net.Http"
#r "Microsoft.WindowsAzure.Storage"
#r "Newtonsoft.Json"
open System
open System.Net
open System.Net.Http
open Microsoft.Azure.WebJobs.Host
type Item = { id: string; comment: string }
let Run(req: HttpRequestMessage, output: byref<Item>, log: TraceWriter) =
let item = { id = "Some ID"; comment = "test comment" }
output <- item
async {
// createResponse has a red line beneath it
return req.createResponse(HttpStatusCode.Created)
} |> Async.StartAsTask
當viewieng在VS代碼這個文件中,有createResponse
下方的紅線。
當我把鼠標放在createResponse
上時,錯誤信息是The field, constructor or member 'createResponse' is not defined.
。這是因爲單聲道版本System.Net.Http
不支持createResponse
?
鑑於我不想在本地運行或編譯此文件,有無論如何要告訴Ionide使用不同版本的System.Net.Http
?
這是'CreateResponse ',而不是'createResponse'。錯誤的大寫。 –
剛試過'CreateResponse',但仍然得到相同的錯誤信息。此外,在F#中的所有Azure函數示例中,它都使用小寫版本。換句話說,使用'createResponse',該函數編譯並運行Azure函數時沒有任何問題。 – Martimatix
[這裏是一個例子](https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-http-webhook#http-trigger-sample-in-c),我發現現在。它使用PascalCase。你能指出我使用camelCase的例子嗎?你確定文件「Microsoft.Azure.WebJobs.Host.dll」存在於該位置嗎?您是否嘗試將此腳本逐行發送至F#交互式行? –