Using Microsoft.WindowsAzure.StorageClient.TableServicesContext and detecting concurrency update conflicts

StackOverflow https://stackoverflow.com/questions/16875964

Domanda

The problem is that some classes (DataServiceClientException / DataServiceRequestException / DataServiceResponse) exist in both System.Data.Services.Client.dll and Microsoft.Data.Services.Client.dll. The simple approach would be to use only one of those libraries. Unfortunately:

  • System.Data.Services.Client.dll cannot be removed because it is required for using Microsoft.WindowsAzure.StorageClient.TableServicesContext
  • Microsoft.Data.Services.Client.dll is required for Microsoft.WindowsAzure.StorageClient.TableServicesContext on Azure.

Normally these two libraries work fine together. However, implementing the code from here to detect concurrency conflicts results in errors:

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'

because System.Data.Services.Client.DataServiceClientException, DataServiceRequestException, and DataServiceResponse classes cannot be accessed as they exist in both libraries. How does one detect concurrency update conflicts while using Microsoft.WindowsAzure.StorageClient.TableServicesContext?

È stato utile?

Soluzione

The solution is to use C#'s extern alias feature.

  1. Expand the references section of your project.

  2. Right click on System.Data.Services.Client and choose properties.

  3. Change Aliases from "global" to "system" or something else.

and the project builds fine.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top