Thursday, September 9, 2010

Why Does "Go to Definition" And Intellisense Not Work Properly For Referenced Projects in VS.NET

Recently I was working with a solution containing (3) projects in VS.NET2010. When I would right-click an item (i.e. a method) from another project and state "Go To Definition" (F12 key does the same thing), the Object Browser window would open as opposed to going to the actual method or class definition.

My 1st step was to delete the project references between projects, and make sure to re-add them from the "Projects" tab. Upon doing this, the answer of why this problem was occurring appeared:


The project I was working with was a project recently upgraded to VS.NET 2010. Somehow, the other 2 projects in my solution when upgrading to VS.NET 2010 remained targeted at the .NET Framework 3.5. When referenced .dlls target a different Framework, they are treated as file references and not project references and therefore the "Go to Definition" and other Intellisense features related to those references does not work properly.

The fix? Get all projects targeting the same .NET Framework if you can. You can do this by right-clicking the project in "Solution Explorer" and selecting "Properties". Select the "Compile" tab and then select "Advanced Compile Options...". From in this dialog window, you can change the targeted framework of the project. Upon completing this for each of my other (2) projects still targeting the .NET Framework 3.5, I removed the project references and re-added them for good practice to cover all steps possible. I then cleaned and re-built the solution. After I did this the "Go To Definition" functionality and associated Intellisense was working properly again.

1 comment:

  1. You make me save a lot of time. Keep the good work!!!!

    ReplyDelete