ServiceStack:部署导致FileLoadException,可以';t加载System.Runtime.

本文关键字:加载 Runtime System 可以 部署 FileLoadException ServiceStack | 更新日期: 2023-09-27 18:25:55

我有一个非常简单的ServiceStack服务正在运行,它来自一个路径/api/Translate/。。。。这在本地非常有效。我可以查看XML、JSON等

然而,当我将项目部署到实时环境中时,调用服务的结果是:

<TranslateResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="">
- <ResponseStatus>
  <ErrorCode>FileLoadException</ErrorCode> 
  <Message>Could not load file or assembly 'System.Runtime.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)</Message> 
  <StackTrace>at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit) at System.RuntimeType.GetCustomAttributes(Type attributeType, Boolean inherit) at ServiceStack.WebHost.EndPoints.Utils.FilterAttributeCache.GetResponseFilterAttributes(Type responseDtoType) in C:'src'ServiceStack'src'ServiceStack'WebHost.EndPoints'Utils'FilterAttributeCache.cs:line 51 at ServiceStack.WebHost.Endpoints.EndpointHost.ApplyResponseFilters(IHttpRequest httpReq, IHttpResponse httpRes, Object responseDto) in C:'src'ServiceStack'src'ServiceStack'WebHost.EndPoints'EndpointHost.cs:line 205 at ServiceStack.WebHost.Endpoints.RestHandler.ProcessRequest(IHttpRequest httpReq, IHttpResponse httpRes, String operationName) in C:'src'ServiceStack'src'ServiceStack'WebHost.EndPoints'RestHandler.cs:line 64</StackTrace> 
  </ResponseStatus>
  </TranslateResponse>

TranslateResponse是我健康的DTO。ResponseStatus不是我的。我已经检查了.NET版本目标,并将System.Runtime.Serialization设置为"复制本地",并手动将DLL包含在/bin文件夹中。

但它仍然不起作用。我哪里错了?

ServiceStack:部署导致FileLoadException,可以';t加载System.Runtime.

解决了它。

它包含了一个使用可移植类库项目构建的项目。那件事似乎太好了,不可能是真的。删除了(这解决了其他问题,主要是MVVM实现)和所有工作。