我是 mono/linux 的新手,我尝试使用 mod_mono 在 ubuntu/apache2 上托管我现有的 asp.net mvc3 网站。一切正常,除了对 ServiceStack 服务的调用在反序列化服务的响应时似乎失败(该服务位于托管在不同进程中的同一台计算机上)。我查看了单声道 gac,并且组件就在那里(正确的版本/ key )。此外,如果我从 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
最佳答案
我也遇到了同样的问题。发生这种情况是因为 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/
关于asp.net-mvc-3 - 无法加载类型 'System.Runtime.Serialization.Json.DataContractJsonSerializer',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14367685/