Could not load file or assembly System.Web.WebPages.Deployment
Solution 1
Please try the following steps.
- Check the Version of System.Web.Webpages in your References. Say Your Version is=X.X.X.X
2.In Webconfig
a.Add the assembly first
<assemblies>
<add assembly="System.Web.WebPages, Version=X.X.X.X, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
b.Bind the assembly for runtime
<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.Make sure you have added correct key
<appSettings>
<add key="webpages:Version" value="X.X.X.X"/>
</appSettings>
This worked for me. Hope It'll help you too.
Solution 2
I wrote a long post about this on my personal blog to document the problem for my future use, but I will just put the solution here for anyone else to use:
You need to install WebMatrix
Long story short the required DLLs are missing from the GAC MSIL and they need to be installed. You can install both versions of WebMatrix 1.0.0.0 and 2.0.0.0 as they can coexist just fine; or just install the one you need:
+--------------------------+---------------------------------------------------------------------+-------------+ | Installer name | URL | DLL Version | +--------------------------+---------------------------------------------------------------------+-------------+ | AspNetWebPages.msi | https://www.microsoft.com/en-us/download/confirmation.aspx?id=15979 | 1.0.0.0 | | AspNetWebPages2Setup.exe | https://www.microsoft.com/en-us/download/details.aspx?id=34600 | 2.0.0.0 | +--------------------------+---------------------------------------------------------------------+-------------+
Clickable links
- https://www.microsoft.com/en-us/download/confirmation.aspx?id=15979
- https://www.microsoft.com/en-us/download/details.aspx?id=34600
Solution 3
I resolved this problem adding line below in web.config
of project...
Before I marked in MANAGE NUGET "Microsoft.AspNet.Mvc/5.1.2", "Microsoft ASP.NET Web Pages/3.1.2", I try anything but nothing works (really!! uninstall VS and read a lot articles)
<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>
Good lucky
Solution 4
In my case this was due to corrupted assembly being referenced which happened due to crash restart of my laptop.
To fix this please following these steps
Clean all the files in the following folders of your project or you can simply click on clean project and clean solution
- \bin
- \obj
Clean the Appdata temp folder for my Win 7 machine its located here C:\Users\your_username\AppData\Local\Temp\Temporary ASP.NET Files in windows 7
Hope this helps!
Admin
Updated on July 09, 2022Comments
-
Admin almost 2 years
Im working developing a system web page and suddenly appears this error:
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.
I already verify my xml files configuration, and everything look good. This is the stack trace:
[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
-
Jan Bühler about 9 yearsI have this entry and still have the problem. Like User37… wrote, one needs an entry for System.Web.WebPages.Deployment as well, which is curious - publicKeyToken is the same. For me, the problem appeared after clearing the global assembly cache which messed up my .net framework installation quite badly.
-
Vagus about 6 years"oldVersion" is a big range,the "newVersion" is your [System.Web.WebPages.Deployment.dll] version;the [dll] version you can get it in "C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v2.0\Assemblies"
-
dyslexicanaboko almost 5 yearsThis worked for me, but it really really makes me angry that this problem just kind of popped up out of no where. I was migrating myself from an older laptop to a newer one at work and my site refused to load. I tried doing all kinds of things and this is what worked. Thank you for figuring this out.
-
Gwasshoppa over 2 yearsThis worked for me when I was installing a brand new laptop with VS2022 and had an IIS website that needed this installed.