1

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?

1
  • The best approach here is to match versions that Sitecore is using. Changing web.config without transforming is usually not recommended as it might bring even more issues when i.e. upgrading Sitecore to newer version. If some dll's are messed up it is always possible to check assembly list i.e. for 10.3 sitecoredev.azureedge.net/~/media/… or by downloading web deploy package. There is not much we can do about this untli Sitecore upgrades their packages to newer.
    – Kamil C
    Commented Jan 2, 2023 at 23:10

2 Answers 2

2

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.

4
  • This worked. But when I add a controller rendering, it shows the same error. Assembly 'Stratum.Feature.Metadata, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'System.Web.Mvc, Version=5.2.9.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'System.Web.Mvc, Version=5.2.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
    – sukesh
    Commented Jan 5, 2023 at 11:07
  • Strangely, it is not showing that for another controller rendering which in code has a higher version 5.2.9.0
    – sukesh
    Commented Jan 5, 2023 at 11:09
  • This does seem strange. Sometimes binding redirects are updated or removed when changing nuget packages. Is there any chance the redirect might have been removed from web config and republished? If not, you mention one rendering working when this one doesn't, I'm assuming they are from different projects? Can you confirm all projects have exact same properties (.net version etc). Any other differences between them? Does each view folder have its own web config Commented Jan 5, 2023 at 18:34
  • All projects are .Net 4.8. Each Views folder has its own web.config, but I'm not publishing any of those. Just the custom DLLs. Not even the *.pdb
    – sukesh
    Commented Jan 6, 2023 at 3:22
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.