Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Go to Definition (F12) opens Object Browser instead of Code View

I'm running VS2005, and when I right click on an object and select Go to Definition it brings me to the object browser instead of the actual code.

Is there some settings that I can change to fix this? Note: it works properly for C# solutions, I am having the problem with Basic.

like image 764
Kevin Avatar asked Jan 27 '10 20:01

Kevin


People also ask

How do I enable F12 in Visual Studio?

Enter Tools > Options > Environment > Keyboard and press the Reset button. Click OK to save changes.

How to enable Go to Definition in Visual Studio?

If you are a keyboard user, place your text cursor somewhere inside the symbol name and press F12. If you are a mouse user, either select Go To Definition from the right-click menu or use the Ctrl-click functionality described in the following section.

What is Peek Definition in Visual Studio?

You can use the Peek Definition command to view and edit code without switching away from the code that you're writing. Peek Definition and Go To Definition show the same information, but Peek Definition shows it in a pop-up window, and Go To Definition shows the code in a separate code window.


3 Answers

I usually see this when I have a reference to the library added as a "binary" reference rather than a "project" reference. You might need to remove the reference and add it back from the projects tab.

like image 123
Eric Nicholson Avatar answered Oct 18 '22 22:10

Eric Nicholson


This can also be caused by mismatched versions of the .Net framework in your advanced compile options.

http://blogs.msdn.com/blogfiles/bethmassi/WindowsLiveWriter/MigratinganOutlookClienttoVisualStudio20_CB9A/image_4.png

I noticed that one of my projects was set as .net 3.5 and another was .net 4.0.

When I clicked Go To Definition (f12) on the .net 4.0 project, the code in the .net 3.5 project would only be shown in the object browser.

Luckily I am able to change both to be the same without any issues, but those with established code libraries may need to beware when changing the .net version.

like image 33
Ash Clarke Avatar answered Oct 18 '22 23:10

Ash Clarke


I saw this too while using Visual Studio 2015, in (C/C++) native projects, after switching between different git branches. The solution is to close VS, go in $(SolutionDir) and delete the .sdf file, then reopen the solution.

like image 3
Chris Bechette Avatar answered Oct 18 '22 23:10

Chris Bechette