【问题标题】:Azure Storage Tables ExecuteAsync Hangs on Retrieve TableOperationAzure 存储表 ExecuteAsync 在检索 TableOperation 时挂起
【发布时间】:2015-10-28 18:22:27
【问题描述】:

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

违规代码是 Retrieve TableOperation 到此处显示的 Azure 存储表:

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 存储表适用于这两个应用程序。

问题是,为什么这在一个应用程序中有效,而在另一个应用程序中无效?

【问题讨论】:

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


    【解决方案1】:

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

    违规应用的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 版本。

    【讨论】:

      【解决方案2】:

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

      "Newtonsoft.Json": "9.0.1"
      

      【讨论】:

        猜你喜欢
        • 2015-01-30
        • 2020-08-04
        • 2020-12-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-04-23
        • 2012-10-11
        • 2014-06-17
        相关资源
        最近更新 更多