SLP
SLP

Reputation: 311

Why is Resharper showing a red 'Cannot Resolve Symbol' error?

I have Resharper 10 installed in Visual Studio 2013. My solution contains a view .cshtml file that displays a date using Razor. However, Resharper displays the DateTime with a red warning highlight, and prompts me to import the System.DateTime namespace - please see the linked image:

enter image description here

The strange thing is that when my colleagues open the solution on their machines - exactly the same code, using the same version of VS2013 with the same Resharper version - there is no Resharper error.

The namespaces section of the Web.config file in the Views folder looks like this:

<namespaces>
    <add namespace="System.Web.Mvc" />
    <add namespace="System.Web.Mvc.Ajax" />
    <add namespace="System.Web.Mvc.Html" />
    <add namespace="System.Web.Routing" />
</namespaces>

If I add the System namespace, ie:

<add namespace="System" />

.. then the issue goes away. But - this doesn't explain why the issue only appears on one machine, and not on others.

I've tried cleaning the solution, suspending & resuming Resharper, clearing the Resharper cache, deleting the .suo file for the project, etc.

This seems so simple, but I really cannot figure out why R# would warn me on one machine, but not on others, when the code and environment seem to be identical.

The solution builds and runs successfully, without any warnings. If I disable Resharper, the error disappears.

Any suggestions? Could Resharper's warning be a result of some wider configuration issue on my machine?

Upvotes: 1

Views: 1857

Answers (1)

iJungleBoy
iJungleBoy

Reputation: 5638

I've had similar issues after cleaning up my PC. So in my case I uninstalled an old visual studio and some dependencies (which were clearly marked as VS 2010), but that also ended up removing stuff in my older .net libraries. So ReSharper complained - and it could always be fixed by specifically referencing specific libraries.

My recommendation

  1. Check what versions of .net your VS project is expecting
  2. check that you have this version in your GAC (or if not, compare to the setup of your colleagues)
  3. if you don't have the version, either upgrade the project to a newer .net, or re-install the older .net libraries, OR change your config-file to map the versions, allowing the new version to step in for the old ones.

Upvotes: 0

Related Questions