我有一个建立在 ASP.NET MVC4、.NET 4.0 上的网站
它部署在运行 IIS7 的服务器上。
我做了一些小改动
该站点在我的开发机器(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/