尝试在Mac上的MVC 6应用程序中从Azure TableStorage读取数据。 它可以在PC上运行,但在Mac上用它时会出现这个错误:
TypeLoadException: Could not load type 'Microsoft.WindowsAzure.Storage.Core.Executor.RESTCommand`1[Microsoft.WindowsAzure.Storage.Table.TableResult]' from assembly 'Microsoft.WindowsAzure.Storage, Version=4.3.2.0, Culture=neutral, PublicKeyToken=null'.
Microsoft.WindowsAzure.Storage.Table.TableOperation.ExecuteAsync (Microsoft.WindowsAzure.Storage.Table.CloudTableClient client, System.String tableName, Microsoft.WindowsAzure.Storage.Table.TableRequestOptions requestOptions, Microsoft.WindowsAzure.Storage.OperationContext operationContext, CancellationToken cancellationToken) [0x00000] in <filename unknown>, line 0Stack Query Cookies Headers Environment
TypeLoadException: Could not load type 'Microsoft.WindowsAzure.Storage.Core.Executor.RESTCommand`1[Microsoft.WindowsAzure.Storage.Table.TableResult]' from assembly 'Microsoft.WindowsAzure.Storage, Version=4.3.2.0, Culture=neutral, PublicKeyToken=null'.
Microsoft.WindowsAzure.Storage.Table.TableOperation.ExecuteAsync (Microsoft.WindowsAzure.Storage.Table.CloudTableClient client, System.String tableName, Microsoft.WindowsAzure.Storage.Table.TableRequestOptions requestOptions, Microsoft.WindowsAzure.Storage.OperationContext operationContext, CancellationToken cancellationToken) [0x00000] in <filename unknown>
Microsoft.WindowsAzure.Storage.Table.CloudTableClient.ExecuteAsync (System.String tableName, Microsoft.WindowsAzure.Storage.Table.TableOperation operation, Microsoft.WindowsAzure.Storage.Table.TableRequestOptions requestOptions, Microsoft.WindowsAzure.Storage.OperationContext operationContext, CancellationToken cancellationToken) [0x00000] in <filename unknown>
Microsoft.WindowsAzure.Storage.Table.CloudTable+<>c__DisplayClass4+<<ExistsAsync>b__5>d__0.MoveNext () [0x00000] in <filename unknown>
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>
System.Runtime.CompilerServices.TaskAwaiter`1[System.Boolean].GetResult () [0x00000] in <filename unknown>
使用System.Net.Http
关注此discussion并安装kpm
包后,我开始收到新错误:
An unhandled exception occurred while processing the request.NullReferenceException: Object reference not set to an instance of an object
Microsoft.WindowsAzure.Storage.Shared.Protocol.HttpClientFactory.BuildHttpClient[TableResult] (Microsoft.WindowsAzure.Storage.Core.Executor.RESTCommand`1 cmd, System.Net.Http.HttpMessageHandler handler, Boolean useVersionHeader, Microsoft.WindowsAzure.Storage.OperationContext operationContext) [0x00000] in <filename unknown>, line 0
注意:
我在System.Net.Http
中安装了"aspnetcore50": { "dependencies": { ... } }
软件包,但似乎必须将其安装在公共dependencies
知道为什么会发生这种情况以及如何解决它?
答案 0 :(得分:1)
您无法在aspnetcore50
下使用Azure Storage .NET客户端,它不适用于此运行时。您需要将其提取到aspnet50
(现在为dnx451
)。