Azure存储表ExecuteAsync挂起检索TableOperation

时间:2015-10-28 18:22:27

标签: c# .net azure hang azure-table-storage

给定两个包含库的C#应用​​程序(Web,Test,Console或其他),运行时,一个应用程序挂起,另一个应用程序运行完美。

违规代码是此处显示的Azure存储表的检索TableOperation

private async Task<bool> FindByIdAsync<TData>(string rowKey)
    where TData : class, ITableEntity
{
    var table = GetTable<TData>();
    var operation = TableOperation.Retrieve<TData>(
        rowKey.GeneratePartitionKey(), rowKey);
    var result = await table.ExecuteAsync(operation);
    ...
}

用于设置连接的所有参数在两个应用程序中都是相同的,并且代码在同一台机器上运行。写入Azure存储表适用于两种应用程序。

问题是,为什么这在一个应用程序中起作用而在另一个应用程序中起作用?

2 个答案:

答案 0 :(得分:3)

问题的原因是无法加载Newtonsoft.Json。如果库引用的Newtonoft版本不在依赖程序集绑定允许的范围内,则会发生故障。这是一个例子:

  

违规应用程序的app.config / web.config

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
       <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
       <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
    </dependentAssembly>
</assemblyBinding>
  

工作申请的app.config / web.config

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
       <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
       <bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
    </dependentAssembly>
</assemblyBinding>
  

请注意版本范围增加到支持7.0.0.0。

更新您的项目的配置文件不能正常工作将允许它找到从引用的库中包含的Newtonsoft.Json的版本。

答案 1 :(得分:0)

感谢。我有同样的问题,但有一个后台应用程序。该应用程序使用Json作为配置文件,但没有Newtonsfot.Json条目。我添加了最新兼容版本的条目。

"Newtonsoft.Json": "9.0.1"