asp.net-mvc - IIS7 上的 MVC 4 网站 - 因细微更改而中断(AutoMapper?)

标签 asp.net-mvc asp.net-mvc-4 iis automapper

我有一个建立在 ASP.NET MVC4、.NET 4.0 上的网站

它部署在运行 IIS7 的服务器上。
我做了一些小改动

  • 添加了 AutoMapper(使用 nuget 包)并将其用于控制​​器之一
  • 添加了一个从 ApiController 派生的新 Controller (其他 Controller 派生自 Controller)

  • 该站点在我的开发机器(Cassini 和 IIS)上运行良好。

    当我将新版本发布到服务器时,它不起作用并显示错误页面(如下)。
    我不确定是什么原因以及如何解决它。请你帮帮我好吗?

    更新 1

    带有 ApiController 但没有 AutoMapper 的版本运行良好。

    “/”应用程序中的服务器错误。

    无法加载文件或程序集“System.Core,Version=2.0.5.0,Culture=neutral,PublicKeyToken=7cec85d7bea7798e,Retargetable=Yes”或其依赖项之一。给定的程序集名称或代码库无效。 (来自 HRESULT 的异常:0x80131047)

    说明:在执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其在代码中的来源的更多信息。

    异常详细信息:System.IO.FileLoadException:无法加载文件或程序集“System.Core,版本=2.0.5.0,Culture=neutral,PublicKeyToken=7cec85d7bea7798e,Retargetable=Yes”或其依赖项之一。给定的程序集名称或代码库无效。 (来自 HRESULT 的异常:0x80131047)

    源错误:

    执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常来源和位置的信息。

    程序集加载跟踪:以下信息有助于确定无法加载程序集“System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes”的原因。

    警告:程序集绑定(bind)日志已关闭。
    要启用程序集绑定(bind)失败日志记录,请将注册表值 [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) 设置为 1。
    注意:有一些与程序集绑定(bind)失败日志相关的性能损失。
    要关闭此功能,请删除注册表值 [HKLM\Software\Microsoft\Fusion!EnableLog]。

    堆栈跟踪:

    [FileLoadException:无法加载文件或程序集“System.Core,版本=2.0.5.0,文化=中性,PublicKeyToken=7cec85d7bea7798e,Retargetable=Yes”或其依赖项之一。给定的程序集名称或代码库无效。 (来自 HRESULT 的异常:0x80131047)]
    System.ModuleHandle.ResolveType(RuntimeModule 模块, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) +0
    System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule 模块, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) +493
    System.ModuleHandle.ResolveTypeHandle(Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) +43
    System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) +325
    System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope,Assembly&lastAptcaOkAssembly,RuntimeModuledecoredModule,MetadataTokendecoredToken,RuntimeType attributeFilterType,Boolean mustBeInheritable,Object[]属性,IList派生属性,RuntimeType&MethodsParameters&ctorHas,IRuntimes 208
    System.Reflection.CustomAttribute.GetCustomAttributes(运行时模块装饰模块,Int32装饰元数据 token ,Int32 pcaCount,运行时类型attributeFilterType, bool mustBeInheritable,IList衍生属性, bool isDecoratedTargetSecurityTransparent)+1188
    System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 modifiedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean isDecoratedTargetSecurityTransparent) +36
    System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly 程序集,RuntimeType caType) +128
    WebActivator.AssemblyExtensions.GetActivationAttributes(Assembly assembly) +114
    WebActivator.ActivationManager.RunActivationMethods() +286
    WebActivator.ActivationManager.RunPreStartMethods() +38
    WebActivator.ActivationManager.Run() +56

    [InvalidOperationException:预应用程序启动初始化方法运行在类型 WebActivator.ActivationManager 上引发异常并显示以下错误消息:无法加载文件或程序集 'System.Core,版本 = 2.0.5.0,文化 = 中性,PublicKeyToken = 7cec85d7bea7798e, Retargetable=Yes' 或其依赖项之一。给定的程序集名称或代码库无效。 (来自 HRESULT 的异常:0x80131047)。]
    System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 方法) +691
    System.Web.Compilation.BuildManager.CallPreStartInitMethods() +425
    System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1021

    [HttpException (0x80004005): The pre-application start Initialization Method Run on type WebActivator.ActivationManager 抛出异常并显示以下错误消息: 无法加载文件或程序集 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken =7cec85d7bea7798e, Retargetable=Yes' 或其依赖项之一。给定的程序集名称或代码库无效。 (来自 HRESULT 的异常:0x80131047)。]
    System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +646
    System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +99
    System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +685

    最佳答案

    它是 AutoMapper 3.0.0。

    我已经按照建议使用了 AutoMapper 2.2.1

    https://github.com/AutoMapper/AutoMapper/issues/383

    问题就解决了。

    关于asp.net-mvc - IIS7 上的 MVC 4 网站 - 因细微更改而中断(AutoMapper?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19360041/

    相关文章:

    javascript - Kendo UI - Javascript 事件处理程序(代码分离 + 参数)

    c# - ASP.Net Core MVC Identity - 添加临时( session )声明

    asp.net-mvc-4 - 基本类型的 ASP.NET MVC 4 编辑器模板

    c# - 名为 'DefaultRoute' 的路由已经在路由集合中。路由名称必须是唯一的

    .net - 服务不可用 - 应用程序池无法启动

    c# - AspNetCoreModuleV2问题.NET Core 3.0

    c# - ASP.NET MVC - 我应该使用存储库模式将 ViewModel 写入数据库还是先将它们转换为模型?

    c# - DevExpress 控件的 MVC4 捆绑?

    c# - 如何将文件中的 "0x1B"替换为空,即删除

    javascript - window.opener 在不同的域上工作吗?