ASP.NET MVC 5.1 Upgrade Issue in Views

Jan 23, 2014 at 1:51 PM
Hi, i'm not sure if this error is related to RazorGenerator or ASP.NET in general but I thought I would post it here.

I've just upgraded to ASP.NET MVC 5.1. I used NuGet to do this. The project I have upgraded it for also uses RazorGenerator.MsBuild to embed the views within the assembly. The application builds and runs fine, however when I try to edit one of the views I get loads of red squiggly lines and the following error message appears:

"One or more types required to compile a dynamic expression cannot be found. Are you missing a reference?"

I did a search for this error message and have been through the suggested solutions but none of them apply. I was wondering if this is possibly an issue with RazorGenerator?

I'd appreciate the help. Thanks
Jan 23, 2014 at 6:09 PM
This might be the result of VS tooling - could you update it and check if it solves your squiggly lines issue?
Jan 24, 2014 at 9:02 AM
Thanks but i'm using Visual Studio 2012. I tried installing the 2012 update from:

However the problem still exists.
Jan 24, 2014 at 9:36 PM
I just created a test Mvc5.1 project, and RazorGenerator works fine for me in both VS 2012 and 2013. Can you please test with Use the RazorGenerator branch.
Jan 26, 2014 at 12:22 AM
Thanks I tried the branch you suggested but the following error still appears:

"ASP.NET runtime error: There is no build provider registered for the extension '.cshtml'. You can register one in the <compilation><buildProviders> section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'"

Please note that I do not have .Net 4.5.1 installed and when I ran the application it asked me to either downgrade the project to .Net 4.5 or try and download 4.5.1. First I tried to download .Net 4.5.1 but when it tried to install it threw an error saying ".Net 4.5 and an update is already installed" (I forgot the exact message). I then resorted to the first option and that's when the same problem persisted when trying to view one of the views.
Jan 26, 2014 at 12:26 AM
Not sure what's going on, but it appears that you have some setup issues that are not related to RazorGenerator if you are not able to install 4.5.1. Might want to ask on a general .NET forum.
Jan 27, 2014 at 10:06 AM
Edited Jan 29, 2014 at 9:25 AM
Thanks, I posted it on the Visual Studio forum and I can now open the project in Visual Studio. After doing a build I was able to get the intellisense working.

However I was able to replicate my original problem. Follow the following steps:
  1. Try opening the non-razor generator branch (to prove this is a bug in Visual Studio with ASP.NET MVC 5.1 and not RazorGenerator)
  2. Do a build
  3. Now remove the entire contents of project apart from the Views directory and the packages.config file
  4. Open one of the views and you'll get the error:
"One or more types required to compile a dynamic expression cannot be found. Are you missing a reference?"

This likely comes down to removing the root Web.config file but this is how I built all my applications before running this update. I then used Razor Generator to keep the views within a single assembly.

I'd really appreciate it if you could test this to see if this is an issue my end or a bug in the ASP.NET MVC 5.1 upate for Visual Studio 2012.

Jan 27, 2014 at 5:12 PM
To make sure I understand, are you saying that you now suspect that the issue is not related to RazorGenerator, but can happen with regular MVC 5.1? If so, I would suggest the MVC forum.

I hate to keep sending you to other places, but this forum is strictly related to RazorGenerator, which is a non-Microsoft add-in that supports a different view compilation model. So it's not a great place for general MVC/VS things :)
Jan 27, 2014 at 7:23 PM
Thanks but right now i'm not sure if I've corrupted my version of visual studio. I'm just trying to account for all situations before I try to a fresh install of Visual Studio 2012 and if that fails a format of the hard drive to refresh my version of the .NET framework. I'd really appreciate it if you could test the steps in the bulleted list in my message above to see if you can reproduce the issue I'm getting. If it fails for you as well then I know this is a bug and not down to something I've done wrong.

Jan 27, 2014 at 7:26 PM
Edited Jan 27, 2014 at 7:26 PM
What does Try opening the non razor generator batch mean? Is there a specific application that you're using for testing?
Jan 28, 2014 at 8:50 AM
Oops sorry I meant branch. I've updated my instructions.
Jan 29, 2014 at 12:49 AM
Yes, I get the same warning. If you're sure that didn't happen before, it may be worth asking the MVC team.
Jan 29, 2014 at 9:20 AM
Thanks atleast I know my installation is fine and that Razor Generator is not the cause. I'll see if I can get help from the MVC forum. Thanks again.