“Go To Definition” in Visual Studio only brings up the Metadata

后端 未结 26 2716
夕颜
夕颜 2020-12-07 13:33

I am working in a Web Project in Visual Studio 2008. When I hit F12 (or right-click and select Go To Definition) Visual Studio is consistently going to the Metadata file in

相关标签:
26条回答
  • 2020-12-07 14:06

    I just ran into this problem on VS 2013. Something I could (did?) not isolate was changing the GUID in the CSPROJ file. Since the CSPROJ files are checked into SVN, I could not simply change the GUID on my local dev. Instead, I was constantly SVN reverting the local change each time it happened.

    First, I had to solve the changing GUID problem.

    1. Revert the CSPROJ to the checked-in version.
    2. Open the CSPROJ via a text editor, NOT VS.
    3. Extract value from the pristine CSPROJ file.

      {B1234567-5123-4AAE-FE43-8465767788ED}

    4. Open the SLN file via a text editor, NOT VS.

    5. Locate the Project reference in the solution.

      Project("{FAE12345-3210-1357-B3EB-00CA4F396F7C}") = "Some.Project", "....\assemblies\Some.Project\Some.Project.csproj", "{B7654321-5321-4AAE-FE3D-ED20900088ED}" EndProject

    6. The first GUID listed is the Solution GUID. For every project referenced in your SLN, you should see this value repeated at the first argument. The GUID following the .csproj is the one you want to replace with the pristine GUID.

    This should solve the first problem, but the "Go to Definition" landing in meta data is not solved. In our SLN file, there is a master project (our web site), so its entry in the SLN file should contain a ProjectSection entry with multiple GUID values. Here is an example:

    ProjectSection(ProjectDependencies) = postProject
    {AC50D230-24C4-4DCA-BAAD-355E6AF5EFBD} = {AC50D230-24C4-4DCA-BAAD-355E6AF5EFBD}
    EndProjectSection
    

    Notice the missing GUID in this collection is the one from my pristine project.

    1. Add the missing GUID as the last entry between ProjectSection and EndProjectSection. The format appears to be per-line, and it is {GUID} = {GUID}.
    2. Save the file.
    3. Open your solution.
    4. Right-click a reference in the newly-added project and "Go to Definition."
    0 讨论(0)
  • 2020-12-07 14:07

    The marked solution does not always work. You must make sure that the referenced project GUID in the project files is the correct GUID for the project you are trying to reference. Visual Studio does allow them to get out of synch in some circumstances. You can get the project GUID from the project file with a text editor. So if project A reference project B. Open up project B.csproj in text editor, copy out project GUID from the tag. Then open up project A.csproj in text editor, and make sure that you are using the correct GUID. Search for project name "B" in this case. It should be at . Replace the GUID in the tag with the correct one. Save and reload. Of course also make sure file based references to your projects are removed. You only want project references.

    0 讨论(0)
  • 2020-12-07 14:08

    For those using VS 2017 (I'm at version 15.3.4 at this moment) here are the simple steps:

    1. Open your solution in Windows Explorer and close down Visual Studio
    2. In the explorer menu, select View and ensure that the "Hidden items" checkbox is marked
    3. Navigate to the subfolder .vs\[your solution name]\v15
    4. Delete the .suo file
    5. Restart VS and build your solution

    That fixed it for me: F12 opened the actual source file, not the "from metadata" version.

    0 讨论(0)
  • 2020-12-07 14:09
    1. click on web site menu from VS.
    2. Add reference...
    3. Click on project tab from dialog box
    4. Select ddl
    5. Click on ok button
    0 讨论(0)
  • 2020-12-07 14:09

    Best guess is that you don't have debug information. Maybe you have multiple copies of your assembly on disk and it doesn't have the .pdb file with it.

    Do a search for your assembly names from your projects and delete them all and rebuild.

    0 讨论(0)
  • 2020-12-07 14:10

    I've kill all VS instances, deleted the SUO, launch sln and it worked for me...

    0 讨论(0)
提交回复
热议问题