Description of Problem:
Steps to reproduce the problem:
1. Create a new solution and the Studio hints 3 updates beside "Packages" in solution explorer
2. Right click on "Packages" and select "Update"
3. After update is finished, start debugging the solution and an application exception occurs with the following exception information:
Could not locate Razor Host Factory type: System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=184.108.40.206,
Website started with no problem
How often does this happen?
Every time after updating the Microsoft.AspNet.Mvc package
Root of problem discovered so far, MVC version in both web.config (the root one and the one under views/shared) is not automatically updated to the latest number. Once updated manually, the problem is eliminated.
Matt, is this something the NuGet update should have fixed?
The MVC version is updated in the root Web.config but not the views/shared/Web.config. I see the binding redirect updated:
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="220.127.116.11-18.104.22.168" newVersion="22.214.171.124" />
The only thing I needed to fix was the version in the views/shared/Web.config for the host factoryType:
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=126.96.36.199, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
On Windows you do not need to fix the above, but on the Mac with Mono you do. Ideally it would work on Mono the same way. I am guessing that the host factory type is being redirected on Windows to the correct assembly but this is not happening on Mono.
The NuGet package will not update the views/shared/Web.config file. NuGet only supports updating the Web.config file in the project's root directory.
I cannot reproduce the Web.config file in the project's root directory not being updated. The views/shared/Web.config file will not be updated by NuGet. So NuGet is working as expected on my machine for both Mac and Windows.
My test steps:
1) Create new ASP.NET MVC Razor Project.
2) Update all the NuGet packages.
3) Run the project.
4) See error "Could not locate Razor Host Factory type..."
5) Edit views/shared/Web.config file and update <host factoryType...> to the correct assembly version.
6) Run the project again and see the web page opened with the welcome message displayed.
I was wondering if this issue has ever been resolved?
I tried to add it in like Mr. Ward had mentioned, but it is not working for my project.
I started up a brand new project and was able to get it running. I saw that there were some updates, so I updated them. Two are still currently saying that they need updated and I am receiving the aforementioned issue.
I will attach a screen shot of the results after I updated.
Created attachment 10104 [details]
Created attachment 10105 [details]
With Xamarin Studio 5.7 after updating all the NuGet packages in the ASP.NET Razor project the only change I made to get it to run on the Mac without the "Could not locate Razor Host Factory" error was to update the version in the views/shared/Web.config
for the host factoryType:
System.Web.Mvc, Version=188.8.131.52, Culture=neutral,
Can this be closed?
I don't think so, I suspect it's a bug that Mono is not respecting the binding redirects.
*** Bug 35542 has been marked as a duplicate of this bug. ***