列出脚本.fsx:
#load "AccountDetails.fs"
#r @"..\packages\FSharpx.Core.1.4.120207\lib\FSharpx.Async.dll"
#r @"C:\Program Files\Windows Azure SDK\v1.6\ServiceBus\ref\Microsoft.ServiceBus.dll"
#load "AzureServiceBus.fs"
open AccountDetails
open FSharp.Control
open Microsoft.ServiceBus
open Microsoft.ServiceBus.Messaging
// Let's do some service bus hacking
let tp = TokenProvider.CreateSharedSecretTokenProvider(issuer_name, key)
let asb_uri = ServiceBusEnvironment.CreateServiceUri("sb", ns, "")
let mf = MessagingFactory.Create(asb_uri, tp)
let nm = NamespaceManager(asb_uri, NamespaceManagerSettings(TokenProvider = tp))
module Queue =
let queueDescription name = async {
let! exists = Async.FromBeginEnd(name, nm.BeginQueueExists, nm.EndQueueExists)
return! if exists then Async.FromBeginEnd(name, nm.BeginGetQueue, nm.EndGetQueue)
else Async.FromBeginEnd(name, nm.BeginCreateQueue, nm.EndCreateQueue)
}
并且收到此错误:Script.fsx(22,43):错误 FS0503:无法从此代码位置访问采用 3 个参数的成员或对象构造函数“BeginCreateQueue”。方法“BeginCreateQueue”的所有可访问版本都采用 3 个参数。
所以它告诉我带有 3 个参数的方法无法访问,但有一个带有 3 个参数的可访问版本?
最佳答案
BeginCreateQueue
有两个公共(public)重载。我的猜测是类型推断很难猜测你想要哪一个。尝试添加类型注释:
Async.FromBeginEnd(name,
nm.BeginCreateQueue : string * AsyncCallback * obj -> IAsyncResult,
nm.EndCreateQueue)
如果这不是您想要的重载,请尝试用 QueueDescription
替换 string
。
关于F# 方法指针 "not accessible from this code location",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9216087/