Stack Exchange Network
Stack Exchange network consists of 182 Q&A communities including
Stack Overflow
, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack Exchange
Sitecore Stack Exchange is a question and answer site for developers and end users of the Sitecore CMS and multichannel marketing software. It only takes a minute to sign up.
Sign up to join this community
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I have a fresh instance with
v10.1.2
, which has
System.Web.Mvc 5.2.4
In my Visual Studio solution, I have projects with
.Net 4.8
which has
System.Web.Mvc 5.2.9
.
When I publish the code into the instance, it is only the custom dlls and pdb files. They do not include
System.Web.Mvc
.
But still, the CMS doesn't load and throws an error saying, cannot find the
System.Web.Mvc
version.
To handle this, I have downgraded
Microsoft.AspNet.Mvc to 5.2.4
.
The issue is now resolved.
But for each project and all the new projects, this step needs to be done.
If I include
System.Web.Mvc (5.2.9)
in publish, then the
web.config
of the instance for all environments (
DEV,UAT, PRD
) have to be updated.
What is the better way to handle this?
–
There are two options available to you.
The first and the recommended approach is to do as you have done and downgrade the reference in your visual studio solution to match what is running in the sitecore instance. This will ensure that the sitecore DLLs are running against what was intended and fully tested.
The second approach would be to add a binding redirect to the Web config file. This would look similar to the below:
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="5.2.4.0-5.2.9.0" newVersion="5.2.4.0" />
</dependentAssembly>
This will ensure any previous references, baked into your custom DLL will be redirected to the version that exists in the bin folder.
–
–
–
–
When I publish the code into the instance, it is only the custom DLLs and PDB files. They do not include System.Web.Mvc.
-This is because your project is referred to the DLL(System.Web.Mvc 5.2.9) available in project references.
To handle this, I have downgraded Microsoft.AspNet.Mvc to 5.2.4. The issue is now resolved.
-If you are using any other third-party NuGet packages/DLLs and there are dependencies with the latest MVC DLLs then you must have to refer the latest DLLs and assembly binding needs to be updated in the root web.config
.
Thanks for contributing an answer to Sitecore Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.