Не удалось загрузить файл или сборку System.Web.WebPages.Deployment
Im работает над созданием веб-страницы системы и внезапно появляется эта ошибка:
Could not load file or assembly 'System.Web.WebPages.Deployment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Я уже проверяю конфигурацию файлов xml, и все выглядит хорошо.
Это трассировка стека:
[FileNotFoundException: Could not load file or assembly 'System.Web.WebPages.Deployment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +210
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +242
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +17
System.Reflection.Assembly.Load(String assemblyString) +35
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +122
[ConfigurationErrorsException: Could not load file or assembly 'System.Web.WebPages.Deployment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +12480704
System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +202
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +331
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +148
System.Web.Compilation.BuildManager.ExecutePreAppStart() +172
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1151
[HttpException (0x80004005): Could not load file or assembly 'System.Web.WebPages.Deployment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12601936
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12441597
Ответы
Ответ 1
Попробуйте выполнить следующие действия.
- В <Литературе > проверьте версию System.Web.Webpages. Скажите, что ваша версия = X.X.X.X
2. В Webconfig
a. Сначала добавьте сборку
<assemblies>
<add assembly="System.Web.WebPages, Version=X.X.X.X, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
b.Bind сборка для времени выполнения
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-X.X.X.X" newVersion="X.X.X.X"/>
</dependentAssembly>
</assemblyBinding>
3.Убедитесь, что вы добавили правильный ключ
<appSettings>
<add key="webpages:Version" value="X.X.X.X"/>
</appSettings>
Это сработало для меня. Надеюсь, это тоже поможет.
Ответ 2
Я решил эту проблему добавить строку ниже в web.config
проекта...
До того, как я пометил в MANAGE NUGET "Microsoft.AspNet.Mvc/5.1.2", "Microsoft ASP.NET Web Pages/3.1.2", я пытаюсь ничего, но ничего не работает (действительно!! удалите VS и много читайте статьи)
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages.Deployment" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
Удачи
Ответ 3
В моем случае это было связано с повреждением сборки, связанной с перезагрузкой моего ноутбука.
Чтобы исправить это, выполните следующие действия.
-
Очистите все файлы в следующих папках вашего проекта или просто нажмите на чистый проект и очистите решение
-
Очистите папку temp appdata temp
для моей машины Win 7, расположенной здесь C:\Users\your_username\AppData\Local\Temp\Temporary ASP.NET Files в Windows 7
Надеюсь, это поможет!
Ответ 4
То, что я обычно делаю, - это перейти к машине, где вы скомпилируете код и перейдите в приглашение dos и введите этот
C:> dir System.Web.WebPages.Depl* /s
Возможно, несколько из них обычно находятся в
c:/windows/Microsoft.Net/assembly/GAG_MSIL/System.web.WebPage/v....../
проверьте дату и убедитесь, что она совпадает с System.Web.WebPages.dll
скопируйте его в корзину, где находится ваш целевой компьютер. Это должно устранить проблему.