无法加载类型'System.Runtime.Serialization.Json.DataContractJsonSerializer'

时间:2013-01-16 20:56:23

标签: asp.net-mvc-3 mono ubuntu-12.04 servicestack apache2.2

我是mono / linux的新手,我尝试使用mod_mono在ubuntu / apache2上托管我现有的asp.net mvc3网站。一切顺利,除了对ServiceStack服务的调用,当从服务反序列化响应时该服务似乎失败(该服务位于托管在不同proc中的同一台机器上)。我看过单声道gac,组件就在那里(正确的版本/密钥)。此外,如果我从monodevelop / xsp运行网站一切正常。任何关于为什么类型负载失败的想法都值得赞赏。


    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

我正在使用:


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

1 个答案:

答案 0 :(得分:4)

我遇到了同样的问题。之所以发生这种情况,是因为ServiceStack库在运行时无法找到3.5版本的System.ServiceModel.Web。我将3.5版本的单声道“gac”复制到我的应用程序bin目录中,一切都开始正常工作。您的系统/部署路径可能不同,但这是我使用的:

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