简体   繁体   English

Azure CloudStorageAccount.Parse未处理的异常错误

[英]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. 简而言之,我有应该为我的存储帐户获取容器的代码,其中有1行引发了未处理的异常。

        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. 我正在使用WindowsAzure.Storage 8.1.3和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. 我正在物理Windows Phone,Android手机和Kindle上进行测试,两个Android版本均为5.1,Windows Phone是最新的稳定Win10版本。

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. [0:] System.TypeInitializationException:Microsoft.WindowsAzure.Storage.CloudStorageAccount的类型初始化程序引发了异常。 ---> System.NotImplementedException: The method or operation is not implemented. ---> System.NotImplementedException:未实现该方法或操作。 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. 在C:\\ Program Files(x86)\\ Jenkins \\ workspace \\ release_dotnet_master \\ Lib \\ AspNet \\ Microsoft.WindowsAzure中,位于Microsoft.WindowsAzure.Storage.CloudStorageAccount.Setting(System.String名称,System.String []有效值)[0x00000]。 Microsoft.WindowsAzure.Storage.CloudStorageAccount.cctor()上的Storage.Facade \\ FacadeLib \\ Microsoft.WindowsAzure.Storage.CloudStorageAccount.cs:210在C:\\ Program Files(x86)\\ Jenkins \\ workspace \\ release_dotnet_master \\ Lib中的[0x00000] \\ AspNet \\ Microsoft.WindowsAzure.Storage.Facade \\ FacadeLib \\ Microsoft.WindowsAzure.Storage.CloudStorageAccount.cs:16 ---内部异常堆栈跟踪的结尾---在E中的ServicesDemo.UploadPage.GetContainer()[0x00002]: \\ ServicesDemo \\ ServicesDemo \\ ServicesDemo \\ UploadPage.xaml.cs:66发生未处理的异常。

Looks like your dependencies are not set up correctly. 看来您的依存关系设置不正确。 Can you try removing and readding the dependency on WindowsAzure.Storage? 您可以尝试删除并读取对WindowsAzure.Storage的依赖吗? Can you also describe how you're setting up your project and taking the dependency? 您还能描述一下如何设置项目并获取依赖吗? Thanks! 谢谢!

从连接字符串中删除EndpointSuffix = core.windows.net对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM