Upgrading S#arp to MVC4

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 lets go to the details, I guess you came across tis 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 in your machine

1 Entry point was not found

If its 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 is that 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.  Lets start!

1. Go to all of your web projects in this case if its S#arp its in the presentation layer.  You need to replace all instances of

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


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

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

Next is in system.web.webPages.razor section under host and in system.web under assemblies

which means your old web.config lines which looks 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

  <add key="webpages:Version" value="" />
  <add key="PreserveLoginUrl" value="true" />

3. In Solution Explorer, right-click the project name (if using s#arp its the {ProjectName}.Web.Mvc) and then select Unload Project this will unload you 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:

  <assemblyIdentity name="System.Web.Helpers"
        publicKeyToken="31bf3856ad364e35" />
  <bindingRedirect oldVersion="" newVersion=""/>
  <assemblyIdentity name="System.Web.Mvc"
        publicKeyToken="31bf3856ad364e35" />
  <bindingRedirect oldVersion="" newVersion=""/>
  <assemblyIdentity name="System.Web.WebPages"
        publicKeyToken="31bf3856ad364e35" />
  <bindingRedirect oldVersion="" newVersion=""/>

so it should look like this

8 Add assembly Binding

2 Responses to Upgrading S#arp to MVC4

  1. Pingback: Guide in Using Kendo UI with S#arp Architecture | Raymund Macaalay's Dev Blog

  2. I found that I needed to add this as well to the binding redirects:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: