Could not load file or assembly Microsoft.Data.Services.Client

Neethi Shetty 6 Reputation points
2021-06-30T20:18:52.26+00:00

I have added the reference to these in my csproj file as shown below:
<Reference Include="System.Spatial, Version=5.8.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>$(PkgSystem_Spatial)\lib\net40\System.Spatial.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Data.Edm, Version=5.8.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>$(PkgMicrosoft_Data_Edm)\lib\net40\Microsoft.Data.Edm.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Data.OData, Version=5.8.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>$(PkgMicrosoft_Data_OData)\lib\net40\Microsoft.Data.OData.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Data.Services.Client, Version=5.8.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>$(PkgMicrosoft_Data_Services_Client)\lib\net40\Microsoft.Data.Services.Client.dll</HintPath>
</Reference>

When I run my program i get the following exception:
Exception: -{"Could not load file or assembly 'Microsoft.Data.Services.Client, Version=5.6.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)":"Microsoft.Data.Services.Client, Version=5.6.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"} System.Exception {System.IO.FileLoadException}

Not sure why it is trying to load **5.6.3.0 though I have specified 5.8.1.0 in the Reference version.**

Developer technologies | .NET | .NET Runtime
Developer technologies | C#
{count} vote

1 answer

Sort by: Most helpful
  1. Adam Jachocki 46 Reputation points
    2021-09-09T09:50:37.793+00:00

    First check what version of this dll you have in your output directory. I'll bet that is 5.6.3.0, so:

    • clean your solution
    • delete all obj and bin directories
    • uninstall this package from the whole solution
    • ensure to delete this file in GAC: &userprofile%.nuget\packages\microsoft.data.services - make sure to delete whole directory
    • now you can install from NuGet the required version
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.