我将 ASP.NET MVC 4 Web 应用程序部署到 Windows Server 2003 (IIS 6)。但它不会启动。
最初我为 .NET 4.5 开发了该项目,但当我发现 Windows Server 2003 不支持 .NET 4.5 时,我不得不为 .NET4 重新构建它。这意味着删除所有第三方引用(使用 NuGet),更改在项目属性中将目标构建到 .NET4,然后将引用添加回来。参考了 Ninject、EF 和 Automapper。
当我尝试加载页面时,出现以下错误:
无法从程序集“mscorlib,版本=4.0.0.0,文化=中性,PublicKeyToken=b77a5c561934e089”加载类型“System.Reflection.AssemblyMetadataAttribute”。说明:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。
异常详细信息:System.TypeLoadException:无法从程序集“mscorlib,版本=4.0.0.0,文化=中性,PublicKeyToken=b77a5c561934e089”加载类型“System.Reflection.AssemblyMetadataAttribute”。
源错误:
在执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常起源和位置的信息。
堆栈跟踪:
[TypeLoadException:无法从程序集“mscorlib”加载类型“System.Reflection.AssemblyMetadataAttribute”,版本=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089。]
System.ModuleHandle.ResolveType(RuntimeModule 模块,Int32 typeToken,IntPtr* typeInstArgs , Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) +0
System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) +180
System.Reflection.RuntimeModule.ResolveType(Int32metadata(Int32 ) , 类型[] genericTypeArguments, Type[] genericMethodArguments) +192
System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord,MetadataImport 范围,Assembly& lastAptcaOkAssembly,RuntimeModule decoratedModule,MetadataToken decoratedToken,RuntimeType attributeFilterType,Boolean mustBeInheritable,Object[] 属性,IListderivedAttributes,RuntimeType& attributeType,IRuntimeMethodInfo&ctor,Boolean&ctorHasParameters,Boolean& isVarArg) + 115
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule,Int32 decoratedMetadataToken,Int32 pcaCount,RuntimeType attributeFilterType,布尔 mustBeInheritable,IList derivedAttributes,布尔 isDecoratedTargetSecurityTransparent)+426 System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly 程序集,运行时类型 caType) +103
System.Reflection.RuntimeAssembly.GetCustomAttributes(Type attributeType, Boolean inherit) +64
WebActivator.AssemblyExtensions.GetActivationAttributes(Assembly assembly) +113
WebActivator.ActivationManager.RunActivationMethods() +216
WebActivator.ActivationManager.RunPreStartMethods() +28
WebActivator.ActivationManager.Run () +55[InvalidOperationException:在类型 WebActivator.ActivationManager 上运行的预应用程序启动初始化方法引发异常,并显示以下错误消息:无法从程序集“mscorlib”加载类型“System.Reflection.AssemblyMetadataAttribute”,版本 = 4.0.0.0,文化 = 中性, PublicKeyToken=b77a5c561934e089'..] System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 方法) +423
System.Web.Compilation.BuildManager.CallPreStartInitMethods() +306
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager , IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, 异常 appDomainCreationException) +677[HttpException(0x80004005):在类型 WebActivator.ActivationManager 上运行的预应用程序启动初始化方法引发异常,并显示以下错误消息:无法从程序集 'mscorlib 加载类型'System.Reflection.AssemblyMetadataAttribute',版本 = 4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'..] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9164848 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97 System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +258
有任何想法吗?
编辑:使用 VS2012 开发的网站