Search code examples
azurewcf-data-servicesazure-storageazure-web-roles

Windows Azure and WCF Data Services V3


My question is:
why does WCF Data Services 5.2.0 work under Azure Emulator and not under Azure Staging/Production environment?

I get this error on server:

Could not load file or assembly Microsoft.Data.Services, Version=5.0.0.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)

instead on emulator it works perfectly..

My project reference assemblies are:

  • Microsoft.Data.Services 5.2.0.0
  • Microsoft.Data.Services.Client 5.2.0.0
  • Microsoft.Data.OData 5.2.0.0
  • Microsoft.Data.Edm 5.2.0.0
  • System.Spatial 5.2.0.0
  • Microsoft.WindowsAzure.Storage 2.0.0.0

V3 is very useful to show data in JSON without other libraries.


Solution

  • The problem can be related to the fact that in the .svc file there is an hardcoded reference to the GACed version: 5.0.0.0

    <%@ ServiceHost Language="C#" Factory="System.Data.Services.DataServiceHostFactory, Microsoft.Data.Services, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Service="Forward.TestService " %>
    

    If your dlls have Copy Local attribute set to true, you should be able to remove version and solve the problem

    <%@ ServiceHost Language="C#" Factory="System.Data.Services.DataServiceHostFactory, Microsoft.Data.Services, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Service="Forward.TestService " %>