wcf – 使用Microsoft.Data.Services.Client.dll而不是System.Data.Services.Client.dll导致Azure.StorageClient出现问题

我们有一个使用WCF 5.0和
WindowsAzure SDK的项目.

有两个引用Microsoft.Data.Services.Client.dll和System.Data.Services.Client.dll并且它们存在冲突.如果我删除系统DLL(根据this)我无法使用windowsAzure SDK.如果我删除Microsoft DLL,我无法利用WCF的新功能,特别是OData 3.0版.

删除系统DLL引用后:

cannot convert from
‘System.Data.Services.Client.SaveChangesOptions [c:\Program Files
(x86)\Microsoft WCF Data
Services\5.0\bin.NETFramework\Microsoft.Data.Services.Client.dll]’ to
‘System.Data.Services.Client.SaveChangesOptions’

附加信息:

The best overloaded method match for
‘Microsoft.WindowsAzure.StorageClient.TableServiceContext.SaveChangesWithRetries(System.Data.Services.Client.SaveChangesOptions)’
has some invalid arguments

The type ‘System.Data.Services.Client.DataServiceContext’ is defined
in an assembly that is not referenced. You must add a reference to
assembly ‘System.Data.Services.Client, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089’.

如果我删除对Microsoft.Data.Services.Client的引用并添加对System.Data.Services.Client的引用,那么我们没有错误 – 我们也没有得到WCF 5.0!

最佳答案 我能够很快地重现这个问题. Microsoft.WindowsAzure.StorageClient.Dll对System.Data.Service.Client.Dll具有直接引用依赖性,如下所示,因此,如果您要使用Azure Storage Client API,则必须引用System.Data.Service.Client.Dll在您的应用程序中,确保您不能使用WCF 5.0 SDK提供的oData 3.0.更多信息发布在以下SO问题中:

WCF 5.0 and oData 3.0 API not work with azure table storage

点赞