#.net #asp.net-mvc-3 #iis #automapper
#.net #asp.net-mvc-3 #iis #automapper
Вопрос:
У меня возникает эта проблема при развертывании, я действительно не знаю, как ее решить. Есть идеи?
Server Error in '/' Application.
Could not load file or assembly 'AutoMapper' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
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.BadImageFormatException: Could not load file or assembly 'AutoMapper' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
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.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'AutoMapper' could not be loaded.
=== Pre-bind state information ===
LOG: User = IIS APPPOOLDefaultAppPool
LOG: DisplayName = AutoMapper
(Partial)
LOG: Appbase = file:///C:/inetpub/wwwroot/
LOG: Initial PrivatePath = C:inetpubwwwrootbin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:inetpubwwwrootweb.config
LOG: Using host configuration file:C:WindowsMicrosoft.NETFramework64v2.0.50727Aspnet.config
LOG: Using machine configuration file from C:WindowsMicrosoft.NETFramework64v2.0.50727configmachine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/Temporary ASP.NET Files/root/e22c2559/92c7e946/AutoMapper.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/Temporary ASP.NET Files/root/e22c2559/92c7e946/AutoMapper/AutoMapper.DLL.
LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/bin/AutoMapper.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8013101b). Probing terminated.
Stack Trace:
[BadImageFormatException: Could not load file or assembly 'AutoMapper' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.]
System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMarkamp; stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) 0
System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMarkamp; stackMark, Boolean forIntrospection) 416
System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMarkamp; stackMark, Boolean forIntrospection) 166
System.Reflection.Assembly.Load(String assemblyString) 35
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) 190
[ConfigurationErrorsException: Could not load file or assembly 'AutoMapper' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) 11224200
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() 388
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) 232
System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() 48
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) 210
System.Web.Compilation.BuildProvidersCompiler..ctor(VirtualPath configPath, Boolean supportLocalization, String outputAssemblyName) 76
System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrecompiledApp) 283
System.Web.Compilation.BuildManager.CompileGlobalAsax() 50
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() 676
[HttpException (0x80004005): Could not load file or assembly 'AutoMapper' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.]
System.Web.Compilation.BuildManager.ReportTopLevelCompilationException() 76
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() 1012
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters) 1025
[HttpException (0x80004005): Could not load file or assembly 'AutoMapper' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) 11318198
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) 88
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) 4348404
Информация о версии: Microsoft .NET Framework Версия: 2.0.50727.5446; ASP.NET Версия: 2.0.50727.5420
Ответ №1:
Пул приложений настроен для .NET 2.0:
Информация о версии: Microsoft .NET Framework Версия: 2.0.50727.5446; ASP.NET Версия: 2.0.50727.5420
Развернутая сборка AutoMapper создана для .NET 4.0:
«Эта сборка собрана средой выполнения, более новой, чем загруженная в данный момент среда выполнения, и не может быть загружена».
Это не будет работать вместе. Вероятно, вы можете исправить это, переключив пул приложений на .NET 4.0.
Комментарии:
1. когда я захожу в C:inetpubwwwrootbin сборка есть.
2. Обновлен ответ. Сборка есть, но ее нельзя загрузить в более старую среду выполнения.
3. Спасибо! это из-за того, что я забыл настроить свой apppool!
Ответ №2:
Попробуйте изменить AppPool… Щелкните правой кнопкой мыши на вашем приложении в IIS, Управление приложением => Дополнительные настройки => пул изменений. asp.net пул v4 работал у меня…
Ответ №3:
Проверьте ссылку на библиотеку DLL AutoMapper — возможно, она неправильная. Возможно, вам придется удалить его и добавить обратно.