I got error when press F12 Go to definition in Visual Studio 2015 / C#

后端 未结 6 2036
陌清茗
陌清茗 2021-02-05 01:54

When I press F12 (Go To Definition) in Visual Studio 2015 I get this error message:

One or more errors occured

I already tried:

相关标签:
6条回答
  • 2021-02-05 02:09

    Visual Studio 2015 Update 1 CTP fixes the issue.

    0 讨论(0)
  • 2021-02-05 02:13

    This is an issue with C# and tabs instead of spaces when attempting to hit the metadata of an external assembly. It may be related the inferred position of the insertion point.

    Others have documented this

    There are a couple of Connect tickets here and here and a Github issue on this. There is also a discussion here.

    Visual Studio 2015 Update 1

    This issue is addressed in Update 1 so please install!

    Poor workaround for RTM

    The options dialog remembers the last page and remains there on subsequent opens. I have a keyboard shortcut to open the options pane quickly (Alt + o). I am temporarily changing to spaces, going to definition and then reverting to tabs before making any code changes. This workflow isn't pretty but neither were the 3.0 Nuget issues in VS2015 either (Nuget 3 has improved to date).

    0 讨论(0)
  • 2021-02-05 02:14

    This hack is no longer useful now that the Visual Studio bug is fixed. I'm leaving it here in case it's useful a sample for hacking around similar issues that come up.


    AutoHotKey to the rescue! Fighting tirelessly against the evils of bad keyboard UX.

    Here's how to set up a script that binds Ctrl+F12 to a key sequence that sets space indents, goes to the definition, and then restores tab indents. Use it instead of F12 to go to definitions outside your codebase:

    1. Install AutoHotKey.
    2. Create a new file somewhere named something like FixF12.ahk. Paste into it the script below.
    3. Open your Startup folder. You can get there by typing shell:startup into the Windows Explorer location bar.
    4. Right-click drag FixF12.ahk into Startup and create a shortcut.
    5. Run the shortcut.

    Script for FixF12.ahk:

    #NoEnv
    SendMode Input
    
    ^F12::
    WinGetActiveTitle Title
    IfInString Title, Microsoft Visual Studio
    {
      Send, ^QC{#} tabs{Enter}
      Sleep, 300
      Send, !p
      Sleep, 300
      Send, {Enter}
      Send, {F12}
      Send, !tO
      Sleep, 300
      Send, !k
      Sleep, 300
      Send, {Enter}
    }
    else
    {
      Send, {^F12}
    }
    

    The script is a hack, complete with flashing dialog boxes and a race condition, but it does the job. Don't forget to upvote the bug report in Connect. Hopefully Microsoft will release a fix before Update 1.

    0 讨论(0)
  • 2021-02-05 02:23

    The Visual Studio 2015 Update 1 solved this problem!

    0 讨论(0)
  • 2021-02-05 02:28

    VS 2015 Update 1 should fix this problem.

    I have made an extension which simply enables/disables "Keep tabs" on each call of "GoToDefinition" command, and seems to work: GoToDefinition Fix

    0 讨论(0)
  • 2021-02-05 02:28

    I found that; if you set Keep Tab under Option -> Text Editor -> All Languages -> Tabs, and it's the same under C#, the F12 and Alt + F12 Works just fine.

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