I’m having trouble working out why the following code doesn’t catch the exception. It’s my first go with Async in F# so I’m sure it’s something simple
open System
open Microsoft.WindowsAzure
open Microsoft.WindowsAzure.StorageClient
open System.Windows.Forms
let mutable connection = "UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://ipv4.fiddler"
CloudStorageAccount.SetConfigurationSettingPublisher(fun cName cPublisher ->
cPublisher.Invoke connection |> ignore)
let storageAccount = CloudStorageAccount.Parse connection
let createTable tableName =
let client = storageAccount.CreateCloudTableClient()
async{
try
do! Async.FromBeginEnd(tableName, client.BeginCreateTable , client.EndCreateTable)
MessageBox.Show "Created" |>ignore
with
| :? StorageClientException -> printfn "failed"; MessageBox.Show("failed to create table") |> ignore
| _ -> printfn "Failed with unknown exception"
} |> Async.Start
[<EntryPoint; STAThread>]
let main(args) =
let form = new Form()
let btn = new Button(Text = "Click")
btn.Click.AddHandler(fun _ _ -> createTable "SomeNewTable")
form.Controls.Add btn
let result = form.ShowDialog()
0
If I run this and the table has already been created it says that an exception of type StorageClientException was not handled in the code, specifically pointing at the client.EndCreateTable part of the FromBeginEnd call
Thanks to Don Syme,
The solution is to turn off debugging “Just my code”.
Debug -> Options and Settings -> General -> uncheck “Enable Just My Code (Managed Only)
This is still a problem with the Visual Studio 11 beta that came out with the Windows 8 consumer preview.