Could not load file or assembly 'Microsoft.Web.Infrastructure' or one of its dependencies.
Should you encounter this type of error, consider the following steps:
"Good practice is to back up your Sitecore's<Folder-ends-with-dev.local>
so that you can use this backup whenever you encounter an error."
"Do not override the Sitecore'sweb.config
with Project'sweb.config
."
Check your project's Web.config
file.
See properties of web.config
and you can see below configurations
Due to the "Build Action: Content" setting, your project's Web.config
is published, replacing the Sitecore Web.config
file with your project's Web.config
content.
Sitecore maintains its own web.config
file, accessible at C:\inetpub\wwwroot\<Folder-ends-with-dev.local>\Web.config
.
As a result of this issue, your project's web.config
file overwrites the Sitecore's web.config
.
Change project's web.config
property
Change the "Build Action" to "None".
If "Copy to Output Directory" is selected with any option other than "Do not copy", change it to "Do not copy".
Replace Sitecore's web.config
Go to C:\inetpub\wwwroot\<Folder-ends-with-dev.local>
and replace the Web.config
file with the original Web.config
file. If you lack a fresh web.config
, you can utilize your colleagues' Sitecore web.config
file or a backup web.config
file that functions correctly.
Note:web.config
file is intended for particular Sitecore Version. Use it exclusively with Sitecore Version; otherwise, opt for your colleagues' web.config
or, if you have backed up the dev.local
folder, replace the web.config
from it.
After making all the necessary changes, publish your code again. If you see the expected screen, this indicates that your error has been resolved. However, if you encounter another yellow error page, it suggests that there is another error to address.
What is the actual problem?
If we examine the issue more closely, the root cause is found in the web.config
file. In a fresh web.config
file, you'll find the following for Microsoft.Web.Infrastructure
:
However, in your project's web.config
file, it might be configured as follows:
This discrepancy shows that your project's web.config
specifies a newVersion
of 2.0.1.0
, while Sitecore's web.config
specifies 1.0.0.0
.
Additionally, you'll notice a difference in the oldVersion
attribute between your project's web.config
and Sitecore's web.config
. Your project's web.config
specifies oldVersion="0.0.0.0-2.0.1.0"
, while Sitecore's web.config
specifies oldVersion="0.0.0.0-1.0.0.0"
.
For more information, please visit the Sitecore's website for further details.
Subscribe to my newsletter
Read articles from Dev Kheradiya directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by