IIS7上的MVC 4网站 - 稍作修改(AutoMapper?)

时间:2013-10-14 12:14:54

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

我有一个基于ASP.NET MVC4,.NET 4.0的网站

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

  • 添加了AutoMapper(使用nuget包)并在其中一个控制器中使用

  • 添加了一个从ApiController派生的新控制器(其他控件来自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,Version = 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'无法加载。

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

堆栈追踪:

[FileLoadException:无法加载文件或程序集' System.Core,Version = 2.0.5.0,Culture = neutral,PublicKeyToken = 7cec85d7bea7798e,Retargetable = Yes'或其中一个依赖项。给定的程序集名称或代码库无效。 (HRESULT异常:0x80131047)]    System.ModuleHandle.ResolveType(RuntimeModule模块,Int32 typeToken,IntPtr * typeInstArgs,Int32 typeInstCount,IntPtr * methodInstArgs,Int32 methodInstCount,ObjectHandleOnStack类型)+0    System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module,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,RuntimeModule decoratedModule,MetadataToken decoratedToken,RuntimeType attributeFilterType,Boolean mustBeInheritable,Object [] attributes,IList derivedAttributes,RuntimeType& attributeType,IRuntimeMethodInfo& ctor,Boolean& ctorHasParameters, Boolean& isVarArg)+208    System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule,Int32 decoratedMetadataToken,Int32 pcaCount,RuntimeType attributeFilterType,Boolean mustBeInheritable,IList derivedAttributes,Boolean isDecoratedTargetSecurityTransparent)+1188    System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule,Int32 decoratedMetadataToken,Int32 pcaCount,RuntimeType attributeFilterType,Boolean isDecoratedTargetSecurityTransparent)+36    System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly,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; System.Core,Version = 2.0.5.0,Culture =中性,PublicKeyToken = 7cec85d7bea7798e,Retargetable = Yes'或其中一个依赖项。给定的程序集名称或代码库无效。 (HRESULT异常:0x80131047)。]    System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods)+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):预应用程序启动初始化方法运行类型WebActivator.ActivationManager引发异常,并显示以下错误消息:无法加载文件或程序集&System; 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


1 个答案:

答案 0 :(得分:3)

是AutoMapper 3.0.0。

我按照

的建议使用了AutoMapper 2.2.1

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

问题解决了。

相关问题