F# 方法指针 "not accessible from this code location"

标签 f# azure azureservicebus

列出脚本.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/

相关文章:

python - 我正在尝试将索引推送到 Azurecognitive 搜索,但这会出现错误 ServiceRequestError : EOF occurred in violation of protocol (_ssl. c:2427)

powershell - 使用 Azure powershell 列出容器上的现有 SASToken

F# - 重载函数

f# - 将 F# 3.0 中的 Amazon WSDL Web 服务与类型提供程序结合使用

Azure 流分析和 PowerBI DAX

c# - 如何保证 CosmosDB 数据与 ServiceBus 保持同步,不被死信消息覆盖

azure - 使用可用区在 Azure 服务总线上实现高可用性

asynchronous - 运行超时的异步计算

f# - 需要澄清有关 Microsoft.FSharp.Data.TypeProviders

c# - 如何查看Azure服务总线队列中的所有消息?