简体   繁体   English

当按F12进入Visual Studio 2015 / C#中的定义时出现错误

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

When I press F12 (Go To Definition) in Visual Studio 2015 I get this error message: 当我在Visual Studio 2015中按F12(转到定义)时,我收到此错误消息:

One or more errors occured 发生一个或多个错误

I already tried: 我已经尝试过:

  1. Closing the solution 关闭解决方案
  2. Deleting the .suo file 删除.suo文件
  3. Re-building the solution 重新构建解决方案

.. but that didn't fix it. ..但这并没有解决。

Please help. 请帮忙。

This is an issue with C# and tabs instead of spaces when attempting to hit the metadata of an external assembly. 尝试访问外部程序集的元数据时,这是C#和制表符而不是空格的问题。 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. 这里这里有几张Connect门票以及与此相关Github问题 There is also a discussion here . 还有一个讨论在这里

Visual Studio 2015 Update 1 Visual Studio 2015更新1

This issue is addressed in Update 1 so please install! 此问题已在更新1中解决,因此请安装!

Poor workaround for RTM 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). 我有一个键盘快捷键可以快速打开选项窗格(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). 这个工作流程不是很漂亮,但是VS2015中的3.0 Nuget问题也没有(Nuget 3迄今为止已得到改进)。

VS 2015 Update 1 should fix this problem. VS 2015 Update 1应该可以解决此问题。

I have made an extension which simply enables/disables "Keep tabs" on each call of "GoToDefinition" command, and seems to work: GoToDefinition Fix 我做了一个扩展,它仅在每次调用“ GoToDefinition”命令时启用/禁用“保持选项卡”,并且似乎可以正常工作: GoToDefinition Fix

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. 如果在选项 -> 文本编辑器 -> 所有语言 -> 选项 下设置Keep Tab ,并且在C#下相同,则F12Alt + F12可以正常工作。

This hack is no longer useful now that the Visual Studio bug is fixed. 现在,Visual Studio错误已修复,这种黑客攻击不再有用。 I'm leaving it here in case it's useful a sample for hacking around similar issues that come up. 我将其保留在此处,以防它对于破解即将出现的类似问题很有用。


AutoHotKey to the rescue! AutoHotKey来解救! Fighting tirelessly against the evils of bad keyboard UX. 与不良键盘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. 以下是设置脚本的方法,该脚本将Ctrl + F12绑定到一个键序列,该键序列设置了空间缩进,进入了定义然后恢复了制表符缩进。 Use it instead of F12 to go to definitions outside your codebase: 使用它代替F12可以转到代码库之外的定义:

  1. Install AutoHotKey . 安装AutoHotKey
  2. Create a new file somewhere named something like FixF12.ahk . 在名为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. 您可以通过在Windows资源管理器位置栏中键入shell:startup到达那里。
  4. Right-click drag FixF12.ahk into Startup and create a shortcut. 右键单击将FixF12.ahk拖动到“ Startup然后创建一个快捷方式。
  5. Run the shortcut. 运行快捷方式。

Script for FixF12.ahk : 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. 该脚本是一个hack,具有闪烁的对话框和竞争条件,但可以完成任务。 Don't forget to upvote the bug report in Connect . 不要忘记在Connect中提高bug报告的质量 Hopefully Microsoft will release a fix before Update 1. 希望Microsoft将在Update 1之前发布修复程序。

Visual Studio 2015 Update 1解决了此问题!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何隐藏<summary>在 Visual Studio 代码中按 F12(转到定义)时的 [元数据]</summary> - How to hide <summary> in [metadata] when press F12 (Go to definition) in visual studio code VSCode C#“转到定义”(F12)不起作用 - VSCode C# "go to definition" (F12) not working VS2010 C#:如何在按F12键时查看内部​​类的定义? - VS2010 C#: How to view internal classes definitions when I press F12? Visual Studio转到定义(F12)打开对象浏览器而不是代码视图 - Visual Studio Go to Definition (F12) opens Object Browser instead of Code View (函数,全局变量)之间的Visual Studio 2019脚本标记(在cshtml中)转到定义(F12)不起作用 - Visual Studio 2019 script tags (in cshtml) between (function,global variable) go to definition (F12) doesn't work 如何使用F12在Visual Studio中查看C#代码详细信息? - How to see the c# code detail in visual studio using F12? 如何通过单击F12在Visual Studio 2015中查看依赖项的源代码? - How to view source code of dependencies in Visual Studio 2015 by clicking F12? 当使用不同装配中的步骤定义时,转到定义(F12)不起作用 - Go To Definition (F12) not working when step definitions are used from a different assembly Visual C# 在一天中的特定时间模拟 F12 按键 - Visual C# Simulating F12 keypress at certain time of day Visual Studio Dom Explorer和IE F12工具Dom Explorer之间的区别 - Difference between Visual Studio Dom Explorer and I.E. F12 tools Dom Explorer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM