Andrew Shader
Andrew Shader

Reputation: 21

Could not load type 'System.Runtime.Serialization.Json.DataContractJsonSerializer'

I am new to mono/linux and I've tried to host my existing asp.net mvc3 website on ubuntu/apache2 using mod_mono. Everything goes ok except the calls to a ServiceStack service which seem to fail when deserializing the response from the service (the service is located on the same machine hosted in a different proc). I have looked at the mono gac and the assembly is there (correct version/key). Moreover if I run the website from monodevelop/xsp everything works just fine. Any idea as to why is the type load failing is appreciated.


    Could not load type 'System.Runtime.Serialization.Json.DataContractJsonSerializer' from assembly 'System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

    Stack Trace:

    System.TypeLoadException: Could not load type 'System.Runtime.Serialization.Json.DataContractJsonSerializer' from assembly 'System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
      at ServiceStack.ServiceClient.Web.JsonServiceClient.DeserializeFromStream[List`1] (System.IO.Stream stream) [0x00000] in :0
      at ServiceStack.ServiceClient.Web.ServiceClientBase.HandleResponse[List`1] (System.Net.WebResponse webResponse) [0x00000] in :0
      at ServiceStack.ServiceClient.Web.ServiceClientBase.Send[List`1] (System.String httpMethod, System.String relativeOrAbsoluteUrl, System.Object request) [0x00000] in :0

I am using:


    Mono Runtime Version: 2.10.8.1 (Debian 2.10.8.1-5ubuntu1);
    ASP.NET Version: 4.0.30319.1
    ServiceStack 3.9.32

Upvotes: 2

Views: 1256

Answers (1)

Matt McCabe
Matt McCabe

Reputation: 51

I was having the same issue. It's happening because the 3.5 version of System.ServiceModel.Web can't be found at runtime by the ServiceStack libraries. I copied the 3.5 version out of the mono "gac" into my applications bin directory and everything started working correctly. The paths may be different on your system/deployment but here is what I used:

cp /usr/lib/mono/gac/System.ServiceModel.Web/3.5.0.0__31bf3856ad364e35/System.ServiceModel.Web.dll /var/www/path/to/web/app/bin/

Upvotes: 4

Related Questions