.net - 使用 Microsoft.WindowsAzure.StorageClient.TableServicesContext 并检测并发更新冲突

标签 .net azure-table-storage optimistic-concurrency

问题是 System.Data.Services.Client.dll 和 Microsoft.Data.Services.Client.dll 中都存在某些类(DataServiceClientException/DataServiceRequestException/DataServiceResponse)。简单的方法是 use only one of those libraries .很遗憾:

  • System.Data.Services.Client.dll 无法删除,因为它是使用 Microsoft.WindowsAzure.StorageClient.TableServicesContext 所必需的
  • Azure 上的 Microsoft.WindowsAzure.StorageClient.TableServicesContext 需要 Microsoft.Data.Services.Client.dll。

  • 通常这两个库可以很好地协同工作。但是,实现来自 here 的代码检测并发冲突导致错误:
    Error   1   The type 'System.Data.Services.Client.DataServiceRequestException' exists in both 'C:\Program Files\Microsoft WCF Data Services\5.0\bin\.NETFramework\Microsoft.Data.Services.Client.dll' and 'C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.Services.Client.dll'
    Error   2   The type 'System.Data.Services.Client.DataServiceResponse' exists in both 'C:\Program Files\Microsoft WCF Data Services\5.0\bin\.NETFramework\Microsoft.Data.Services.Client.dll' and 'C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.Services.Client.dll'
    Error   3   The type 'System.Data.Services.Client.DataServiceClientException' exists in both 'C:\Program Files\Microsoft WCF Data Services\5.0\bin\.NETFramework\Microsoft.Data.Services.Client.dll' and 'C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.Services.Client.dll'
    

    因为 System.Data.Services.Client.DataServiceClientException , DataServiceRequestException , 和 DataServiceResponse无法访问类,因为它们存在于两个库中。如何在使用 Microsoft.WindowsAzure.StorageClient.TableServicesContext 时检测并发更新冲突?

    最佳答案

    解决办法是使用C#的extern alias特征。

  • 展开项目的引用部分。
  • 右键单击 System.Data.Services.Client 并选择属性。
  • 将别名从“全局”更改为“系统”或其他名称。

  • 并且该项目构建良好。

    关于.net - 使用 Microsoft.WindowsAzure.StorageClient.TableServicesContext 并检测并发更新冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16875964/

    相关文章:

    c# - "standard"初始化基于 COM 的库的方法是什么

    azure - 如何对Azure表存储表分区运行压力测试?

    elasticsearch - version=1&version_type=external 和 if_seq_no=0&if_primary_term=1 之间的区别

    entity-framework - Entity Framework : about OptimisticConcurrencyException

    c# - ASP.NET Web 应用程序部署方法最佳实践

    c# - 如何保存动态复选框更改

    .net - Umbraco是或否?

    c# - 无法加载文件或程序集 'Microsoft.Azure.Documents.Client - Azure-Table-Api

    azure - 单元测试 Azure 表存储类

    asp.net - 在 Entity Framework 中删除对象时的并发性