By Carmel ShvartzmanIn this tutorial we'll learn how to fix the error "'The type initializer for 'System.Data.Services.Providers.ResourceType' threw an exception.' while deploying an ODATA WCF Data Service in a web host.
The error is caused because there is a specific version of an assembly missing.
Open the references of your MVC Visual Studio app, those related to ODATA, and you'll see something like this :
Microsoft.Data.Services is a version 18.104.22.168 : but the version of the assemblies should be the same. If not so, there could be functions missing and other problems of lack of fitness between them.
Open the Package Manager Console and enter the following expression, to put in sync the ASSEMBLY VERSIONS :
> Install-Package Microsoft.Data.Services -Version 5.2.0
This will bring the required DLL and remove the older version of the assembly.
You can also set in the web.config what will be the new version of the assembly, but it is not required to do so:
<runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Microsoft.Data.Services" publicKeyToken="XXXX" /> <bindingRedirect oldVersion="22.214.171.124-126.96.36.199" newVersion="188.8.131.52" /> </dependentAssembly> </assemblyBinding> </runtime>
Just change the version to the one you need : 184.108.40.206!!
כתב: כרמל שוורצמן