ASP.NET MVC - Cannot Resolve Symbol 'Html', 'Model', 'Request'
When I enable solution wide inspection (and sometimes even when I do not) ReSharper returns errors for just about every single one of my View files in my ASP.NET MVC application, saying that the core ViewPage objects Html, Model, Request, and some others are unknown symbols. If I go to the file and select any part of the unknown symbol and simply retype it the error goes away, but it never stays away. I really like being able to use solution-wide inspection to keep an eye on things, but when it contains 74 errors that are false positives then it's pretty much useless. :\
I am currently using the 5.0 EAP client of resharper, but I was also experiencing this issue in 4.5.
Please sign in to leave a comment.
Nathan, what Visual Studio are you using? Does the problem
happen to a newly created web application? I think, the caches are got corrupted somehow, could you please remove the caches (ReSharper|Options|General|Clear caches) and reopen the project. Would it help?
I'm using Visual Studio 2008. I'll try reseting the caches and report back if the problem occurrs again.
I also have this problem. Clearing the cache had no effect and for some reason I can make it go away by Inherits attribute in the @Page directive then undoing my page. It's like it gives it a kick and reminds it what to do.
Anyway, it's highly annoying and I've had to turn off solution-wide analysis as a result
Could you please create a simple solution which is demonstrating these bugs?
Thanks in advance! Also, what version of MVC do you use? Are there any 'Areas' in your projects?
--
Kirill Falk
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
Since clearing my cache and updating to the latest EAP build of ReSharper I have not noticed the problem again. The projects it was happening in did contain Areas, but that didn't seem to affect which Views had the problem, and which did not.
The problem is that the issue doesn't seem to show up in simple solutions; it only seems to occur for me when the solution starts to contain a lot of projects and code. So, unless you want me to send you my entire solution with a massive amount of code, I'm not sure what I can do other than express my frustration at the bug
Please, try to install the latest nightly build of R# 5.0. Please, let me know if it helps
--
Kirill Falk
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
But my license (Nathan Ridley) only covers version 4.5, which means I'm going to get used to 5.0 features and then have to go back. I'll give it a go but soon I will have a sad face
Ok I have installed the beta and as expected, it doesn't like my license key, so I'm back on the trial. The issue is resolved, but I have some feedback/issues in 5.0 that I have highlighted in the image below:

Nathan Ridley wrote:
You need to download latest EAP builds, there are settings now to disable ASP.NET MVC references.
By the way latest image - you juat apply standard C# quickfix - don't do it and nothing will change.
It's not error, it's brown underscore to shoq there is MVC references (here is implicit controller reference).
I've had this exact issue and using the ReSharper 5.0 Beta 2 doesn't solve it. I've tried resetting caches, toggling ASP.NET MVC references support in Options and restarting Visual Studio in every possible sequence and combination.
Like the original poster, this only becomes an issue in our 32-project solution, not in any of our simpler ones.
Jesper, it would be terrific if you're able to send us your solution for investigation. We're ready to sign any NDA if necessary. If not, I've a strange guess. Could you please do the following:
1. Unload all project except for the one with ASP.NET MVC
2. Make sure MVC stuff is resolved
3. Reload project one by one until MVC things stop resolving.
If such a project is found, I'll have further questions.
It turns out that ReSharper can't cope when the web.config file is gone. We have three configurations and different variants of the web.config file for each, named Web.config.$Configname, renamed to the correct name on build. Adding a proper Web.config resolves the issue. If you could make this work as is, I'd be very happy, but I can't expect you to support this.
Yes, we do not support such a thing (and will not in 5.0). But let's discuss how could we cope with your problem. How do you perform your build process? Is it MSBuild or something elese?
Right now, this is just a post-build action in Visual Studio. We don't have a build system for this yet. Ideally, Microsoft would solve this by including different file variant for different configurations/architectures. That would also solve some other problems of ours with different 32/64 dependencies.
I got it. If you add web.config file, that will be replace by appropriate one while build process, will it work the problem around?
Yes; that's the workaround that we've already devised and that seems to work. I'm happy with this solution.
Oddly, even after emptying the cache and rebuilding I had to go into every view and dirty the text buffer (add a space and then remove it) for Resharper to figure out that the members of `this` (Html, Model, ...) could be resolved. This was a one-time thing, but I had to do this with each and every one of 140 views.
If you just removed ReSharper caches, all the files would be rehighlighted
I did. I tried several times, including closing down Visual Studio. It didn't work. Trust me.
weird
Hello Sergey,
The thing that helps is to make an edit in that file.
This is in R# for Ages.
Regards
Albert
That could only possible if SWEA caches are not cleared while "clear caches". I'll check that with the author of SWEA as he returns from vacation.
I am also experiencing this problem all the time.
I'm quite certain that my problem is due to the use of TFS. When I check in these problems pop up in a few files. All I need to do is to save or checkout the file and the errors will go away.
Anybody else who can confirm this?
Best Regards
Seems I replied to the wrong post, I am sorry.
Here is my reply:
"I am also experiencing this problem all the time.
I'm quite certain that my problem is due to the use of TFS. When I check in these problems pop up in a few files. All I need to do is to save or checkout the file and the errors will go away.
Anybody else who can confirm this?
Best Regards"
Hi,
Could you please try to reproduce this on a simple MVC2 solution under TFS?
Thanks in advance!
Sorry don't have the time for it.
I noticed today that the majority of errors where in display- or editortemplates thought there were errors in some other files as well.
Best regards
Just an update from the OP on this matter... I do not use TFS and I am experiencing this problem.
Just wanted to chime into this thread with my discovery.
I had the same problem described here. Nothing would work -- clearing caches, turning off MVC in the options, removing projects from my solution, etc.
Upon further investigation, I realized I had an error in my web.config. It was a mispelled tag. Not enough to affect my web app at all, but plenty enough to break ReSharper with respect to MVC references.
Hope this helps someone.
Alex,
could you recall what was the typo in web.config?
Thanks in advance.
It wasn't exactly a typo. I was using this construct:
<location path="." inheritInChildApplications="false">
<system.web>
...
</system.web>
</location>
Apparently, "inheritInChildApplications" is not supported in MVC2 or something. Anyhow, it was flagged as an error in the web.config, and when I removed it everything worked fine. I noticed that pretty much any kind of error in the web.config would cause the same problem with Resharper not seeing the MVC classes