Click here to Skip to main content
Click here to Skip to main content

Upgrading S#arp to MVC4

, 5 Oct 2013
Rate this:
Please Sign up or sign in to vote.
How to upgrade S#arp to MVC4

Editorial Note

This article appears in the Third Party Product Reviews section. Articles in this section are for the members only and must not be used by tool vendors to promote or advertise products in any way, shape or form. Please report any spam or advertising.

First of all, I can assure you that S#arp will work on MVC4 and I am using Sharp Architecture 2.0.4. We just recently migrated and tested 2 large S#arp projects and it is fully working and is running in production.

Now let's go to the details, I guess you came across this article either because you want to use MVC4 with your S#arp project or you got this “Entry point was not found” error because you recently installed MVC4 on your machine.

1 Entry point was not found

If it's the second reason yes, it is MVC4 doing it and not S#arp your project just auto referenced the latest MVC version. Now to fix that issue, you need to upgrade your S#arp project to use MVC4 this can also be used in any .NET web projects that is using MVC3 so this guide is not specific to S#arp projects. Let's start!

  1. Go to all of your web projects in this case if it's S#arp it's in the presentation layer. You need to replace all instances of:
    System.Web.Mvc, Version="3.0.0.0"
    System.Web.WebPages="", Version="1.0.0.0"
    System.Web.Helpers="", Version="1.0.0.0"
    System.Web.WebPages.Razor="", Version="1.0.0.0"

    with:

    System.Web.Mvc="", Version="4.0.0.0"
    System.Web.WebPages="", Version="2.0.0.0"
    System.Web.Helpers="", Version="2.0.0.0"
    System.Web.WebPages.Razor="", Version="2.0.0.0"

    You can see this in 3 different locations.

    First is in the configSections which means your old web.config lines which looks like this:

    9 Old Config Section

    will become like this:

    10 New Config Section

  2. Next is in system.web.webPages.razor section under host and in system.web under assemblieswhich means your old web.config lines which look like this:

    2 Old config

    will become like this:

    3 New config

    Finally, check also under the views folder, there is one web.config file in there.

    11 Other Web Config

    Old one will be like this:

    12 Other Web Config OLD

    Change it so it looks like this:

    13 Other Web Config NEW

    In the root Web.config file, update or add the following is not yet there:

    <appSettings>
      <add key="webpages:Version" value="2.0.0.0" />
      <add key="PreserveLoginUrl" value="true" />
    </appSettings>
  3. In Solution Explorer, right-click the project name (if using s#arp it's the {ProjectName}.Web.Mvc) and then select Unload Project. This will unload your project and you can edit what’s in the code behind. Once unloaded, right-click the name again and select Edit {ProjectName}.csproj.

    Find the ProjectTypeGuids element and replace {E53F8FEA-EAE0-44A6-8774-FFD645390401} with {E3E379DF-F4C6-4180-9B81-6769533ABE47}.

    So from this:

    6 Replace GUID

    will become like this:

    7 Replace GUID

    Save and close file you just edited, right-click the project, and then select Reload Project. This will load the project with the new settings.

  4. If the project references any third-party libraries that are compiled using older versions of MVC (definitely S#arp is), then you have to add the following three bindingRedirect elements under the configuration section in your web.config:

    Here is what you need to add:

    <dependentAssembly>
      <assemblyIdentity name="System.Web.Helpers"
            publicKeyToken="31bf3856ad364e35" />
      <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/>
    </dependentAssembly>
    <dependentAssembly>
      <assemblyIdentity name="System.Web.Mvc"
            publicKeyToken="31bf3856ad364e35" />
      <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="4.0.0.0"/>
    </dependentAssembly>
    <dependentAssembly>
      <assemblyIdentity name="System.Web.WebPages"
            publicKeyToken="31bf3856ad364e35" />
      <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/>
    </dependentAssembly>

So it should look like this:

8 Add assembly Binding


Filed under: CodeProject, Configuration, Programming Tagged: ASP.Net MVC, C#, S#arp Architecture

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Raymund Macaalay
Technical Lead
New Zealand New Zealand
http://nz.linkedin.com/in/macaalay
http://macaalay.com/
Follow on   Twitter   Google+   LinkedIn

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 5 Oct 2013
Article Copyright 2013 by Raymund Macaalay
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid