2

Listing 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)
     }

And am getting this error: 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.

So it's telling me that the method with 3 arguments is inaccessible, but that there's an accessible version with 3 arguments?

1 Answer 1

2

There are two public overloads of BeginCreateQueue. My guess is type inference is having trouble guessing which one you want. Try adding a type annotation:

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

If that's not the overload you want, try substituting QueueDescription for string.

Sign up to request clarification or add additional context in comments.

3 Comments

This worked, although with different bracketing! I thought, since I passed FromBeginEnd a string, it would know to select the overload with the string? Why didn't it?
I think the answer is: at the point that BeginCreateQueue is used the type of name has not yet been inferred. Type inference can only use type information available up to to the point of usage. Given that, adding a type annotation to name (FromBeginEnd(name : string, ...) should fix it (and requires less typing).
Right, so that would mean that if I wrote 'queueDescription "a"' I wouldn't get the error?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.