Potential Visual Studio Issue: Can't resolve symbol but works fine? - visual-studio

I feel like either this is an issue in Visual Studio or I'm crazy.
Ingredients
I'm using:
Visual Studio Professional 2012 (11.0.61030.00) Update 4
ReSharper 7
xUnit for tests
FluentAssertions in my test code.
The Issue
Just recently, resharper showed me an issue:
I navigated to the file, and sure enough, there seemed to be the issue in the code.
But I'm referencing FluentAssertions:
And if I clean and rebuild the entire solution, I get no errors:
And all of the tests even run correctly:
Questions
Why would this just start showing up after installing Visual Studio Update 4?
What can I do to make it go away?
Is there actually a problem with something, or if tests & code run fine and no errors appear, is it not an issue at all?
First time I've seen anything like this so I'd appreciate any insight.

This could be for several reasons, such as NuGet package restore - if the packages (and therefore the assemblies) weren't there when the solution was opened, ReSharper will mark them as undefined. It's usually pretty good at noticing and reindexing when the assemblies are added, but perhaps it missed them here. Sometimes opening the file again will cause the errors to be reindexed, sometimes it requires the solution to be closed and reopened.
Alternatively, and what is probably the most likely way to fix, is to go to ReSharper -> Options -> General and click Clear Caches. ReSharper will rebuild the solution cache, and should reindex everything and get rid of the errors.

In this case, the solution appears to be the old "Restart the PC" trick.
If anyone knows how an issue such as this could be resolved without restarting the PC, I'm happy to award you the answer.

Check you don't have any old missing references, just noticed on my solution the same issue removing old missing references did the trick for me.

Related

Why do I always have to build solution on opening in Visual Studio 2013

My first question on SO, so please be gentle ;-)
As per the title, when I open any solution in Visual Studio 2013, the solution is opening in an unbuilt state, reporting lots of errors etc. I haven't been able to track anyone else down having the same issue on SO, and have already been through nearly all the VS->Tools->Options and compared with a colleague's settings, but not found a solution so far. As soon as I press Ctrl+Shift+B the solution builds and all errors go away.
At the moment this isn't such an issue as the solutions and projects are all relatively small, but when we do return to one of our larger projects, the added delay will become annoying.
Thanks
Stuart
Turns out the sea of red is in fact Resharper complaining and not Visual Studio.
Have tried various fixes as per this link ReSharper "can not resolve symbol" even when project builds, but still not resolved.
For now have turned off code inspection in Resharper.

Cannot edit checked out file (TFS) in Visual Studio 2013

Since I changed my windows password I can no longer type into a checked out file in Visual Studio 2013! Where before I just needed to start typing and it would check out the file in the background, now it won't even allow me to type into the file after I manually check the file out, from the solution explorer! It's as if VS 2013 is ignoring the keyboard on the project under source control. It's fine for other projects even project's under source control!
I think I remember seeing this before with older versions of Visual Studio and resolved it with a "Go online" option but I can't see that option in VS 2013, or the project is not "off line" so the option is not available.
This is obviously related to the TFS setting on the project but I simply cannot get past it. I am blocked and would appreciate any suggestions.
I suspended Resharper and restarted Visual Studio 2013. Once I reopened it the problem was gone. Resuming Resharper caused the problem to emerge again.
The solution is quite large so maybe that is it. Before putting Resharper into suspend mode I tried switching off code analysis thinking the workload is just too great, but that didn't help. The suspend did though. I hope this helps anyone else with the same issue.
All I have to do now is to figure out how to get Resharper back in the game without the problem coming back. We rely on Resharper as it is an wonderful tool. Since the solution has many projects in it, I am going to try create a smaller solution with my web project and just reference the other projects as assemblies. Maybe that will help
Update:
Clearing the resharper cache as suggested by Alexander resolved the original issue.
I'd like to add Alexander's comment as answer, since it helped me exactly to solve the issue:
Clean R# (ReSharper) caches by deleting all folders (and files) from the path
C:\Users\{User Name}\AppData\Local\JetBrains\ReSharper\v8.2\SolutionCaches\
and then reopen the solution.
Note: (Thanks to Antak for providing this info!)
You can paste
%userprofile%\AppData\Local\JetBrains\ReSharper\v8.2\SolutionCaches
into file explorer's path textbox (open it via Win+E, or use Win+R and paste the path into the command window), this will resolve the physical path into your user's directory automatically.
This happened to me. All my JavaScript files went "dead." By "dead" i mean that all the normal VS intellisense coloring/functionality was gone; js files were un-editable, although Resharper was still working sort of; all other non-js files seems to be normal. In addition to Resharper, I had also previously installed Web Essentials and was using both tools.
First, I cleared the R# caches as mentioned above by Alexander. After restarting VS, this DID NOT work. JS files still dead.
Then i disabled Web Essentials. Then I restarted. THIS WORKED.
I then re-enabled Web Essentials, restarted again, and all seems to be OK. Am crossing my fingers....
I too had this problem with the latest version of ReSharper (9.0.0.0), but clearing the cache as stated above did not work. I actually had to go into my ReSharper options (ReSharper -> Options -> General) and click the "Clear Caches" button. Once I did this and restarted VS everything is working again.
Try: /safemode
I had a similar problem where I could not edit most of my files, but I could edit *.ps1 files.
I don't have TFS, I do have resharper and other plugins.
What worked for me was:
Start visual studio in safe mode: C:\..\IDE>devenv /safemode
Close VS.
Start VS normally.
That probably has the same effect as suspending and resuming resharper, but I'm not sure which plugin could be causing the problem. If you are having trouble this is something you could try.
I hit the refresh(restart) and it solved a similiar problems so maybe you better try that before an IDE restar. ctrl shift F5

Cannot resolve symbol issue with resharper but code compiles

I know this has been asked before, but there was no solution to the problem, and it was last year, so I thought maybe someone has found something to solve this by now.
I am using VS2010 with SP1. before installing the SP1 there was no problem. if I uninstal re# it works fine. I have an ASP.Net website and some other projects. The classes from the other projects are not recognized, resharper suggests using the other project, so I do so, it puts it up at the usings, then the using also gets a "cannot resolve symbol".
I have tried the suggestions they gave in 2011 here but nothing.
if I delete the _Resharper. and restart vs, it will work for 5 seconds, then all red again...
hope someone found a solution to this since then...thanks
Edit: I have noticed it does this with Web Services
Although this question is rather old it happended to me today. I solved it by going to menu Tools -> Options -> Resharper
Click on Options and press Clear Caches button followed by Save.
Then just click on the Suspend Now followed by Resume Now button to restart Resharper and your code should be ok again.
EDIT: happened to me again. Clearing caches helped. The only thing changed is that "Clear caches" is hidden under General tab in resharper options.
I was having the same problem with one of my projects. I reported the issue to JetBrains and they requested a VS solution which has the problem.
So, I decided to spend a few hours trying to narrow down the problem as much as possible. I found out that the issue is related to a tool I use which strips out information from .DLLs.
If I don’t strip the .DLLs, Resharper works fine without showing any “cannot resolve symbol” errors. However, If I do strip the .dll, then ReSharper starts to show these “cannot resolve symbol” errors. In both cases, Visual Studio compiles the program and the program runs fine.
I am working with JetBrains to get the issue resolved.
In the mean time, I am able to workaround the problem by using versions of my .DLLs which do not have any information stripped out of them.
in visual studio, Tools -> Options -> Resharper, Press Suspend Now
delete the folder _ReSharper.*
Tools -> Options -> Resharper, Press Resume Now

What's the reason for error message? I am using VS 2010 professional edition

What's the reason for error message "The snapshot is out of date and cannot be used anymore because type tree has been updated, A new snapshow needs to be acquired"?
This error appeared right after I launched VS2010 and added username/pwd to connect to TFS repository.
I am using VS 2010 professional edition.
It happened to me with VS2012 as well after loading the project without source control binding, a local simple WinForms project. All I needed to do was Clean & Rebuild. After that the problem was solved.
This is a bug in Visual Studio. According to http://connect.microsoft.com/VisualStudio/feedback/details/742959/the-snapshot-is-out-of-date "We've taken a closer look at this problem and it isn't one that we'll be able to solve in the next release of Visual Studio."
They recommend waiting around until the background language parser service is done (or, in other words, don't try to be too productive there partner.) My experience is that closing all documents, cleaning the solution, rebuilding it and then closing and re-opening with a pause after does remove the error.
Until you do something silly, like edit code. Then all bets are off again as to when it reoccurs.
I had a similar issue with VS2012 and after rebuilding the solution twice, I still saw the same error message.
Following an advice from a post from this site, I closed the Designer tab, reopened it from the Solution Explorer, and the problem was resolved.
I got this error too, but after I unload project and reload project, the problem was resolved.
Simply restarting Visual Studio 2012 was a workaround for me, but it kept happening about every hour and having to restart visual studio that often was very annoying.
I also found this post which suggests that the Productivity Power Tools are the problem and to simply turn off the Automatic Brace Completion in Tools->Options->Productivity Power Tools. Since making this change I haven't seen the error message again :)
I'll note though that I am using Visual Studio 2012 and the OP is using Visual Studio 2010, but the Productivity Power Tools are available for VS 2010 too, so this may still fix the problem in VS 2010.
The same issue persists in VS2013, but no amount of Clean/Rebuild or restarting VS will help. The only way I can do a successful publish, is to disable the AutoT4MVC extension.
I got this error too. I closed Visual Studio 2012 and opened it again and the error was gone.
I got this error when I had conflicting class names / namespaces. I was referencing a UserControl from a different DLL in my XAML file which had the same name as my XAML file (class name). Maybe this helps.
I used Visual Studio 2012, and just faced this error on my Windows 8. It seems like Turning off the VM and restarting Visual Studio fixed the issue.
I just got this with VS2010.
I had a form with a user control (UCa) with a user control (UCa) from a different project on it. Made a change to the UCb then flicked to the designer for the form and boom! Snapshot error.
Resolved by a full clean and then rebuilding just the UCb project before building the rest of the project.
I'm using Visual Studio 2012, and I got this error when starting Visual Studio, letting TFS connect to the server, and THEN opening my solution. The fix was simply closing VS and launching the solution directly.
I'll throw my two cents in here as well.
I've tried every combination of Clean, Rebuild, Restart, etc. What I've found is that restarting Visual Studio usually makes the problem go away for at least one Publish. Here's the weird part, though. You can also fix the problem by doing absolutely nothing. If you just let Visual Studio sit for about a minute or two, and then publish, it will usually work just fine. There's some background voodoo going on here, and waiting for it to finish seems to do the trick.
I have a solution with two parts that need published. One is a WCF service application, and the other is the ASP.NET MVC5 website itself. Anytime I publish the services, and then try to publish the site I'll see this error. I can publish the services, restart VS, and then publish the site, OR I can publish the services, go get a drink, and then publish the site. As long as I give VS a chance to "settle" between any kind of rebuild and the publishing of the site, everything seems to work as expected.
Take a walk, come back, problem solved. OR if you don't have the time. Clean, Rebuild, Restart, Publish (lather, rinse, repeat).

Visual Studio removes line break on start

I have the problem that Visual Studio (or maybe Resharper?) removes line breaks when I try to start my application. This happens in a way that when I press F5 or click on the run button with the mouse that a line break at the line where the cursor was the last time will be removed which is extremely annoying.
I have not tried so many things yet because I really don't know where to start. I never experienced this problem before and was always working with the same setup:
Visual Studio 2010
Resharper 6.1.1
Other plugins I use but which were installed after the problem (so I think they should not be related to the problem):
AnkhSvn
TeamCity
Example:
Before:
public void test(){
int x = 5;
}
After running the solution:
public void test(){
int x = 5;}
Edit: This issue seems to be related to Resharper - so hopefully they will be able to fix this issue as I never had this with any previous versions. (http://devnet.jetbrains.net/message/5456038#5456038).
This is a problem with Dexexpress Dim#ster patch. If you delete licenses.licx and compile in the source code. Not happend. The problem is when you open a form and licenses.licx is created again. Is you uninstall the patch this dissapear. But I dont understand why deactivating Resharper the problem gone too. But without patch and resharper + devexpress trial working fine.
The problem is the patch.
I'd do this before reinstalling:
Uninstall All plugins
Type devenv.exe /resetsettings
Now try and use your code as described without plugins. Slowly add back your plugins if its ok and check after each is installed if the problem manifests itself. if not it was some setting in one and its now gone, if it comes back after one is installed you have a good thing to look at.
Just blatting the environment means you'll never find out whats causing it, which would annoy me :)
Have a look at ReSharper's Braces-settings: http://www.jetbrains.com/resharper/features/code_formatting.html#Code_Style_Configuration_and_Sharing (1st screenshot). Try changing those settings according to your needs.
If you're a member of a team, maybe someone else enabled sharing of "code style settings". See the previous link for that, 2nd screenshot.
Does it also occur when you just build the project?
In the build options try doing clean project, then open close the program. After this do a rebuild project. Also make sure the project is in debug mode for testing =)!
Delete the settings resharper in solution. Helped me.
I know that this question is a little bit old. But this may help anyone who encountered the same error with resharper and devexpress controls. I've tried all the above instructions, but the nothing works. BTW I'm using visual studio 2017 with resharper 2017.2.2 and devexpress 17.2.3
This what works for me.
Open build&run window in resharper. Click Resharper>Windows>Build&Run to open the the window then select "Enable 'Resharper Build'. Open any file in text editor and move the cursor at the end of any line of codes or on any empty line and try to build the project to see if it works.
Hope this will help.
At this point I would suggest uninstalling and reinstalling VS. Then add ReSharper and any of your extensions one at a time.
I had the same problem. I use this prebuilt-event script
break>$(ProjectDir)\Properties\licenses.licx
I have ReSharper 10.0.2, VS2013, DevExpress Components and VisualSVN.

Resources