2017-05-30 154 views
0

總之,我的代碼應該是爲我的存儲帳戶獲取容器,1行是拋出未處理的異常。Azure CloudStorageAccount.Parse未處理的異常錯誤

 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; 
    } 

它無法在第一行實際上做任何事情,

account = CloudStorageAccount.Parse(Configuration.StorageConnectionString); 

它調用看起來像這樣的配置,

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

實際的帳戶名是所有小寫密鑰從門戶網站複製,實際上整個連接字符串被完全複製。我正在使用WindowsAzure.Storage 8.1.3和Xamarin.Forms 2.3.5.239-pre3。 我正在測試物理Windows Phone,Android手機和Kindle,兩個Android版本都是5.1,Windows手機是Win10最新穩定版本。

歡迎所有的想法。

完整的錯誤是這樣的,用它來做什麼,你會的,但它提出了在上述行:

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# 

**有趣的是,這表明了在輸出窗口太...

[0:] System.TypeInitializationException:'Microsoft.WindowsAzure.Storage.CloudStorageAccount'的類型初始值設定項引發異常。 ---> System.NotImplementedException:該方法或操作未實現。 C:\ Program Files(x86)\ Jenkins \ workspace \ release_dotnet_master \ Lib \ AspNet \ Microsoft.WindowsAzure中的Microsoft.WindowsAzure.Storage.CloudStorageAccount.Setting(System.String name,System.String [] validValues)[0x00000]中的 .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 ---內部異常堆棧跟蹤--- 的末尾在ServicesDemo.UploadPage.GetContainer()[0x00002 ]在E:\ ServicesDemo \ ServicesDemo \ ServicesDemo \ UploadPage.xaml.cs中:66 發生未處理的異常。

+0

你能粘貼你得到的實際錯誤嗎? –

+0

@MariaInesParnisari編輯了包含錯誤的問題。 –

回答

1

看起來您的依賴關係設置不正確。你可以嘗試刪除並讀取WindowsAzure.Storage的依賴關係嗎?你還可以描述你如何設置你的項目,並依賴它?謝謝!

+0

經過相當多的壓力和重複出現的錯誤,與存儲或認知服務無關,我決定從頭開始重建項目。大部分相同的代碼,但在不同的基礎上,這已經解決了這個問題,所以謝謝。 –