在Xamarin应用程序中实例化CloudStorageAccount会导致未处理的异常

时间:2017-05-09 14:25:23

标签: c# azure xamarin

this篇文章之后,我创建了一个空白的Xamarin表单应用,将WindowsStorage.Azure包添加到了PCL和Android应用中(我现在删除了iOS和UWP)它只是一个测试应用程序)

  <package id="WindowsAzure.Storage" version="8.1.1" targetFramework="portable45-net45+win8+wp8+wpa81" />

并尝试与库进行交互,但是只要我做任何事情,应用程序就会以未处理的异常崩溃:

enter image description here

无论我做什么,都可以创建一个新的StorageCredentials对象:

var creds = new StorageCredentials("something", "other");

或新的CloudStorageAccount:

var storageAccount = CloudStorageAccount.Parse(storageConnectionString);

我也一样。 我已经通读了github documentation并且没有理由这样做。

有没有人遇到过这个问题并且可以帮助解决这里出错的问题?

修改

我可以从debu窗口看到它抛出一个NotImplementedException:

05-09 14:45:16.452 D/Mono    ( 3772): DllImport attempting to load: '/system/lib/liblog.so'.
05-09 14:45:16.476 D/Mono    ( 3772): DllImport loaded library '/system/lib/liblog.so'.
05-09 14:45:16.476 D/Mono    ( 3772): DllImport searching in: '/system/lib/liblog.so' ('/system/lib/liblog.so').
05-09 14:45:16.476 D/Mono    ( 3772): Searching for '__android_log_print'.
05-09 14:45:16.476 D/Mono    ( 3772): Probing '__android_log_print'.
05-09 14:45:16.476 D/Mono    ( 3772): Found as '__android_log_print'.
05-09 14:45:16.480 I/MonoDroid( 3772): UNHANDLED EXCEPTION:
05-09 14:45:16.485 I/MonoDroid( 3772): System.AggregateException: One or more errors occurred. ---> System.NotImplementedException: The method or operation is not implemented.
05-09 14:45:16.485 I/MonoDroid( 3772):   at Microsoft.WindowsAzure.Storage.Auth.StorageCredentials..ctor (System.String accountName, System.String keyValue, System.String keyName) [0x00006] in C:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\AspNet\Microsoft.WindowsAzure.Storage.Facade\FacadeLib\Microsoft.WindowsAzure.Storage.Auth.StorageCredentials.cs:77 
05-09 14:45:16.485 I/MonoDroid( 3772):   at Microsoft.WindowsAzure.Storage.Auth.StorageCredentials..ctor (System.String accountName, System.String keyValue) [0x00000] in C:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\AspNet\Microsoft.WindowsAzure.Storage.Facade\FacadeLib\Microsoft.WindowsAzure.Storage.Auth.StorageCredentials.cs:71 
05-09 14:45:16.485 I/MonoDroid( 3772):   at TestApp.Droid.MainPage+<StartPolling>d__3.MoveNext () [0x0001d] in D:\XamarinAzureStorageTest\TestApp.Droid\TestApp.Droid\MainPage.xaml.cs:27 
05-09 14:45:16.485 I/MonoDroid( 3772):    --- End of inner exception stack trace ---
05-09 14:45:16.485 I/MonoDroid( 3772):   at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00014] in /Users/builder/data/lanes/4468/f913a78a/source/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2157 
05-09 14:45:16.485 I/MonoDroid( 3772):   at System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken) [0x00052] in /Users/builder/data/lanes/4468/f913a78a/source/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:3189 
05-09 14:45:16.485 I/MonoDroid( 3772):   at System.Threading.Tasks.Task.Wait () [0x00000] in /Users/builder/data/lanes/4468/f913a78a/source/mono/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:3054 
05-09 14:45:16.485 I/MonoDroid( 3772):   at TestApp.Droid.MainPage.StartPolling_Clicked (System.Object sender, System.EventArgs e) [0x0004e] in D:\XamarinAzureStorageTest\TestApp.Droid\TestApp.Droid\MainPage.xaml.cs:55 
05-09 14:45:16.485 I/MonoDroid( 3772):   at Xamarin.Forms.Button.Xamarin.Forms.IButtonController.SendClicked () [0x00020] in C:\BuildAgent\work\ca3766cfc22354a1\Xamarin.Forms.Core\Button.cs:125 
05-09 14:45:16.485 I/MonoDroid( 3772):   at Xamarin.Forms.Platform.Android.AppCompat.ButtonRenderer+ButtonClickListener.OnClick (Android.Views.View v) [0x0000b] in C:\BuildAgent\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\ButtonRenderer.cs:298 
05-09 14:45:16.485 I/MonoDroid( 3772):   at Android.Views.View+IOnClickListenerInvoker.n_OnClick_Landroid_view_View_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_v) [0x00011] in /Users/builder/data/lanes/4468/b16fb820/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.Views.View.cs:1806 
05-09 14:45:16.485 I/MonoDroid( 3772):   at (wrapper dynamic-method) System.Object:0f149978-de2e-4679-a635-699ceeddec42 (intptr,intptr,intptr)
05-09 14:45:16.485 I/MonoDroid( 3772): ---> (Inner Exception #0) System.NotImplementedException: The method or operation is not implemented.
05-09 14:45:16.485 I/MonoDroid( 3772):   at Microsoft.WindowsAzure.Storage.Auth.StorageCredentials..ctor (System.String accountName, System.String keyValue, System.String keyName) [0x00006] in C:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\AspNet\Microsoft.WindowsAzure.Storage.Facade\FacadeLib\Microsoft.WindowsAzure.Storage.Auth.StorageCredentials.cs:77 
05-09 14:45:16.485 I/MonoDroid( 3772):   at Microsoft.WindowsAzure.Storage.Auth.StorageCredentials..ctor (System.String accountName, System.String keyValue) [0x00000] in C:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\AspNet\Microsoft.WindowsAzure.Storage.Facade\FacadeLib\Microsoft.WindowsAzure.Storage.Auth.StorageCredentials.cs:71 
05-09 14:45:16.485 I/MonoDroid( 3772):   at TestApp.Droid.MainPage+<StartPolling>d__3.MoveNext () [0x0001d] in D:\XamarinAzureStorageTest\TestApp.Droid\TestApp.Droid\MainPage.xaml.cs:27 <---
05-09 14:45:16.500 W/art     ( 3772): JNI RegisterNativeMethods: attempt to register 0 native methods for android.runtime.JavaProxyThrowable
05-09 14:45:16.604 D/Mono    ( 3772): DllImport searching in: '__Internal' ('(null)').
05-09 14:45:16.604 D/Mono    ( 3772): Searching for 'java_interop_jnienv_throw'.
05-09 14:45:16.604 D/Mono    ( 3772): Probing 'java_interop_jnienv_throw'.
05-09 14:45:16.604 D/Mono    ( 3772): Found as 'java_interop_jnienv_throw'.
Thread finished: <Thread Pool> #4
The thread 'Unknown' (0x4) has exited with code 0 (0x0).
Thread finished: <Thread Pool> #5
05-09 14:45:57.900 D/Mono    ( 3772): [0x9b2de930] worker finishingThe thread 'Unknown' (0x5) has exited with code 0 (0x0).

1 个答案:

答案 0 :(得分:0)

  

...将最新的稳定版本安装到解决方案中的所有项目中....

回复:第3步https://docs.microsoft.com/en-us/azure/storage/storage-xamarin-blob-storage

Azure存储使用本机功能/功能,因此您不仅需要在PCL项目中安装软件包,还需要在每个本机应用程序项目中安装软件包。