简体   繁体   English

“Microsoft.WindowsAzure.Storage.CloudStorageAccount”的类型初始值设定项在Xamarin.forms中引发了异常错误

[英]The type initializer for 'Microsoft.WindowsAzure.Storage.CloudStorageAccount' threw an exception error in Xamarin.forms

I'm working on AzureStorage cloud solution provided by Xamarin. 我正在研究Xamarin提供的AzureStorage云解决方案。 https://developer.xamarin.com/guides/xamarin-forms/cloud-services/storage/azure-storage/ https://developer.xamarin.com/guides/xamarin-forms/cloud-services/storage/azure-storage/

And this is what I got in GetContainer() method. 这就是我在GetContainer()方法中得到的。

The type initializer for 'Microsoft.WindowsAzure.Storage.CloudStorageAccount' threw an exception “Microsoft.WindowsAzure.Storage.CloudStorageAccount”的类型初始值设定项引发异常

I applied my connection string in the sample project and it worked, but not in my own project. 我在示例项目中应用了我的连接字符串并且它有效,但不在我自己的项目中。

Has anyone ever faced this issue? 有没有人遇到过这个问题? Please help me. 请帮我。

Thanks in advance. 提前致谢。

Error message : 错误信息 :

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 <667a5fa37f124e50ab7a68ecb3437b13>:0
 at Microsoft.WindowsAzure.Storage.CloudStorageAccount..cctor () [0x00000] in <667a5fa37f124e50ab7a68ecb3437b13>:0
 --- End of inner exception stack trace ---
 at MyTenantWorld.AzureStorage.GetContainer (MyTenantWorld.ContainerType containerType) [0x00020] in <9816076ee17d42efaf1050c5169a4310>:0
 at MyTenantWorld.AzureStorage+<UploadFileAsync>d__3.MoveNext () [0x0001a] in <9816076ee17d42efaf1050c5169a4310>:0
 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <3fd174ff54b146228c505f23cf75ce71>:0
 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <3fd174ff54b146228c505f23cf75ce71>:0
 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <3fd174ff54b146228c505f23cf75ce71>:0
 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <3fd174ff54b146228c505f23cf75ce71>:0
 at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <3fd174ff54b146228c505f23cf75ce71>:0
 at MyTenantWorld.SettingsPage+<SaveData>d__20.MoveNext () [0x00309] in <9816076ee17d42efaf1050c5169a4310>:0
 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <3fd174ff54b146228c505f23cf75ce71>:0
 at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) [0x00000] in <3fd174ff54b146228c505f23cf75ce71>:0
 at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in <d855bac285f44dda8a0d8510b679b1e2>:0
 at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <d855bac285f44dda8a0d8510b679b1e2>:0
 at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <d855bac285f44dda8a0d8510b679b1e2>:0
 at at (wrapper dynamic-method) System.Object:a4fed05a-cd7a-4756-85bb-5dd975374042 (intptr,intptr)

As the GetContainer method defined under AzureStorage.cs as follows: 由于AzureStorage.cs下定义的GetContainer方法如下:

static CloudBlobContainer GetContainer(ContainerType containerType)
{
     var account = CloudStorageAccount.Parse(Constants.StorageConnection);
     var client = account.CreateCloudBlobClient();
     return client.GetContainerReference(containerType.ToString().ToLower());
}

It seems that the error was thrown by CloudStorageAccount.Parse , but from BergQuester's link about CloudStorageAccount.Parse , we could find that this error is not from the predictable exceptions. 似乎CloudStorageAccount.Parse引发了错误,但是从BergQuester关于CloudStorageAccount.Parse的链接中,我们发现此错误不是来自可预测的异常。

From your stack trace, we could find the error was thrown at Setting(string name, params string[] validValues) from CloudStorageAccount.cs . 从堆栈跟踪中,我们可以在CloudStorageAccount.cs中找到Setting(string name, params string[] validValues)时发生的错误。 I used WindowsAzure.Storage 8.3.0 and tested it under my BruceChen_Mobile.UWP project and PCL project, it could work as expected with my azure storage connection string. 我使用了WindowsAzure.Storage 8.3.0并在我的BruceChen_Mobile.UWP项目和PCL项目下进行了测试,它可以按照我的azure存储连接字符串工作。

I applied my connection string in the sample project and it worked, but not in my own project. 我在示例项目中应用了我的连接字符串并且它有效,但不在我自己的项目中。

I would recommend you checking the packages between your application and the xamarin-forms-samples . 我建议你检查你的应用程序和xamarin-forms-samples之间的包。 Or you could provide a reproducible sample project for us to narrow this issue. 或者您可以为我们提供可重现的示例项目以缩小此问题。

我通过从我的本机项目(不仅仅是在PCL项目中)添加对WindowsAzure.Storage nuget包的引用来修复此问题,因为它需要在这些引用中定义的一些本机实现。

暂无
暂无

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

相关问题 “Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment”的类型初始化程序引发异常 - The type initializer for 'Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment' threw an exception 无法发布到Azure-Microsoft.WindowsAzure.Storage.CloudStorageAccount ctor不匹配 - Cannot publish to Azure - Microsoft.WindowsAzure.Storage.CloudStorageAccount ctor doesn't match 出现错误:Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment&#39;引发异常 - Getting error: Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment' threw an exception &#39;&#39;的类型初始值设定项引发了异常 - The type initializer for '' threw an exception 类型初始值设定项引发了异常 - The type initializer threw an exception Microsoft.WindowsAzure.Storage.dll中出现“Microsoft.WindowsAzure.Storage.StorageException”类型的第一次机会异常 - A first chance exception of type 'Microsoft.WindowsAzure.Storage.StorageException' occurred in Microsoft.WindowsAzure.Storage.dll 类型初始值设定项引发异常 - Type initializer threw an exception C#错误“…的类型初始值设定项引发了异常 - C# Error "The type initializer for … threw an exception “ Microsoft.DataTransformationServices.Project.SharedIcons”的类型初始值设定项引发了异常 - The type initializer for 'Microsoft.DataTransformationServices.Project.SharedIcons' threw an exception “Microsoft.EntityFrameworkCore.Query.QueryableMethods”的类型初始值设定项引发异常 - The type initializer for 'Microsoft.EntityFrameworkCore.Query.QueryableMethods' threw an exception
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM