Shaine Fisher
Shaine Fisher

Reputation: 325

Azure CloudStorageAccount.Parse Unhandled Exception error

In short I have code that is supposed to get the container for my storage account, 1 line is throwing an Unhandled Exception.

        private CloudBlobContainer GetContainer()

    {

        try
        {
            CloudStorageAccount account;
            CloudBlobClient client;
            CloudBlobContainer container;

            account = CloudStorageAccount.Parse(Configuration.StorageConnectionString);
            client = account.CreateCloudBlobClient();
            container = client.GetContainerReference("teststorage");
            return container;
        }
        catch (FormatException fe)
        {
            Debug.WriteLine(fe); return null;
        }
        catch (ArgumentNullException ane)
        {
            Debug.WriteLine(ane); return null;
        }
        catch (ArgumentException ae)
        {
            Debug.WriteLine(ae); return null;
        }
        catch (Exception ex)
        {
            Debug.WriteLine(ex); return null;
        }
        return null;
    }

It fails on the first line to actually do anything,

account = CloudStorageAccount.Parse(Configuration.StorageConnectionString);

The Configuration it is calling looks like this,

    public static class Configuration
{
    public const string StorageConnectionString = "DefaultEndpointsProtocol=https;AccountName=storename;AccountKey=alongaccoutkeything==;EndpointSuffix=core.windows.net";
}

The actual account name is all lower case and the key is copied from the portal, in fact the entire connection string was copied exactly. I am using WindowsAzure.Storage 8.1.3 with Xamarin.Forms 2.3.5.239-pre3. I am testing on a physical Windows Phone, an Android phone and on a Kindle, both Android versions are 5.1, Windows phone is latest stable Win10 build.

All ideas welcome please.

The full error is this, make of it what you will, but it raised on the line mentioned above:

    0xFFFFFFFFFFFFFFFF in System.Diagnostics.Debugger.Mono_UnhandledException_internal  C#
0x1 in System.Diagnostics.Debugger.Mono_UnhandledException at /Users/builder/data/lanes/4009/3a62f1ea/source/mono/mcs/class/corlib/System.Diagnostics/Debugger.cs:122,4 C#
0x20 in object.47865625-a11f-4fd0-83e7-222f80f73ceb C#
0x12 in System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw at /Users/builder/data/lanes/4009/3a62f1ea/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143,13   C#
0x6 in System.Runtime.CompilerServices.AsyncMethodBuilderCore.AnonymousMethod__0 at /Users/builder/data/lanes/4009/3a62f1ea/source/mono/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1018,49    C#
0xC in Android.App.SyncContext.Post.AnonymousMethod__0 at /Users/builder/data/lanes/4009/3a62f1ea/source/xamarin-android/src/Mono.Android/Android.App/SyncContext.cs:35,19  C#
0x11 in Java.Lang.Thread.RunnableImplementor.Run at /Users/builder/data/lanes/4009/3a62f1ea/source/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36,6    C#
0xA in Java.Lang.IRunnableInvoker.n_Run at /Users/builder/data/lanes/4009/3a62f1ea/source/monodroid/src/Mono.Android/platforms/android-25/src/generated/Java.Lang.IRunnable.cs:81,4 C#
0x11 in object.47865625-a11f-4fd0-83e7-222f80f73ceb C#

**Interestingly, this showed up in the output window too...

[0:] System.TypeInitializationException: The type initializer for 'Microsoft.WindowsAzure.Storage.CloudStorageAccount' threw an exception. ---> System.NotImplementedException: The method or operation is not implemented. at Microsoft.WindowsAzure.Storage.CloudStorageAccount.Setting (System.String name, System.String[] validValues) [0x00000] in C:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\AspNet\Microsoft.WindowsAzure.Storage.Facade\FacadeLib\Microsoft.WindowsAzure.Storage.CloudStorageAccount.cs:210 at Microsoft.WindowsAzure.Storage.CloudStorageAccount..cctor () [0x00000] in C:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\AspNet\Microsoft.WindowsAzure.Storage.Facade\FacadeLib\Microsoft.WindowsAzure.Storage.CloudStorageAccount.cs:16 --- End of inner exception stack trace --- at ServicesDemo.UploadPage.GetContainer () [0x00002] in E:\ServicesDemo\ServicesDemo\ServicesDemo\UploadPage.xaml.cs:66 An unhandled exception occured.

Upvotes: 0

Views: 1764

Answers (1)

Peter Marino - MSFT
Peter Marino - MSFT

Reputation: 426

Looks like your dependencies are not set up correctly. Can you try removing and readding the dependency on WindowsAzure.Storage? Can you also describe how you're setting up your project and taking the dependency? Thanks!

Upvotes: 2

Related Questions