2

清单 Script.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): error FS0503: The member or object constructor 'BeginCreateQueue' taking 3 arguments are not accessible from this code location. All accessible versions of method 'BeginCreateQueue' take 3 arguments.

所以它告诉我带有 3 个参数的方法是不可访问的,但是有一个带有 3 个参数的可访问版本?

4

1 回答 1

2

有两个公共重载BeginCreateQueue。我的猜测是类型推断很难猜出你想要哪一个。尝试添加类型注释:

Async.FromBeginEnd(name, 
  nm.BeginCreateQueue : string * AsyncCallback * obj -> IAsyncResult, 
  nm.EndCreateQueue)

如果这不是您想要的重载,请尝试QueueDescription替换string.

于 2012-02-09T17:57:58.423 回答