Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 326
Joshcodes Avatar asked Jun 01 '13 18:06

Joshcodes


People also ask

How should developers approach concurrency in Azure Storage?

In addition to selecting an appropriate concurrency strategy developers should also be aware of how a storage platform isolates changes – particularly changes to the same object across transactions. The Azure storage service uses snapshot isolation to allow read operations to happen concurrently with write operations within a single partition.

What are the Azure storage client libraries for Windows?

The Azure Storage client libraries for .NET offer a convenient interface for making calls to Azure Storage. For more information about Azure Storage, see Introduction to Azure Storage. The latest version of the Azure Storage client library is version 12.x.

Is it possible to force an unconditional update in table service?

Note that unlike the blob service, the table service requires the client to include an If-Match header in update requests. However, it is possible to force an unconditional update (last writer wins strategy) and bypass concurrency checks if the client sets the If-Match header to the wildcard character (*) in the request.

When concurrency is a concern in the queueing service?

One scenario in which concurrency is a concern in the queueing service is where multiple clients are retrieving messages from a queue. When a message is retrieved from the queue, the response includes the message and a pop receipt value, which is required to delete the message.


1 Answers

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.

like image 51
Joshcodes Avatar answered Oct 16 '22 16:10

Joshcodes