2013-12-09 6 views
0

Я развернул веб-приложение ASP.NET MVC 4 на Windows Server 2003 (IIS 6). Но это не начнется.ASP.NET MVC 4 Веб-сайт не запускается - Не удалось загрузить тип «System.Reflection.AssemblyMetadataAttribute»

Первоначально я разработал проект для .NET 4.5, но ему пришлось перестроить его для .NET4, когда я узнал, что .NET 4.5 не поддерживается в Windows Server 2003. Это означало удаление всех сторонних ссылок (с NuGet), изменив цель сборки в свойствах проекта на .NET4, а затем добавив ссылки назад. Ссылки были на Ninject, EF и Automapper.

При попытке загрузить страницу, я получаю следующее сообщение об ошибке:

Could not load type 'System.Reflection.AssemblyMetadataAttribute' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.TypeLoadException: Could not load type 'System.Reflection.AssemblyMetadataAttribute' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[TypeLoadException: Could not load type 'System.Reflection.AssemblyMetadataAttribute' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.]
System.ModuleHandle.ResolveType(RuntimeModule module, 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(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) +192
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) +115
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) +426 System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType 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: The pre-application start initialization method Run on type WebActivator.ActivationManager threw an exception with the following error message: Could not load type 'System.Reflection.AssemblyMetadataAttribute' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'..] System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +423
System.Web.Compilation.BuildManager.CallPreStartInitMethods() +306
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +677

[HttpException (0x80004005): The pre-application start initialization method Run on type WebActivator.ActivationManager threw an exception with the following error message: Could not load type 'System.Reflection.AssemblyMetadataAttribute' from assembly 'mscorlib, Version=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

Любые идеи?

EDIT: Сайт разработан с использованием VS2012

+0

ОК, так что я думаю, что нашел ответ на основе этого http://stackoverflow.com/a/20227810/164297 похоже, что я удалю .NET 4.5 с моей машины – empo

+0

Возможный дубликат [Не удалось загрузить тип ' System.Runtime.CompilerServices.ExtensionAttribute 'from assembly' mscorlib] (http://stackoverflow.com/questions/13748055/could-not-load-type-system-runtime-compilerservices-extensionattribute-from-as) –

ответ

1
Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly mscorlib 

Да, технически это может пойти не так при выполнении кода на .NET 4.0 вместо .NET 4.5. Атрибут был перенесен из System.Core.dll в файл mscorlib.dll в .NET 4.5. Хотя это звучит как довольно неприятное изменение в версии фреймворка, которая должна быть на 100% совместима, атрибут [TypeForwardedTo] должен сделать эту разницу ненаблюдаемой.