visual-studio 摆脱“当前位置没有可用的源代码”。
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/314329/
Warning: these are provided under cc-by-sa 4.0 license.  You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Getting rid of "There is no source code available for the current location."
提问by Lasse V. Karlsen
OK, this is my own fault, but I can't seem to rescue myself.
好吧,这是我自己的错,但我似乎无法自救。
Whenever I try to step into a class that has fields with assignments calling into .NET code, I get a dialog box that contains the text "There is no source code available for the current location.":
每当我尝试进入具有调用 .NET 代码的赋值字段的类时,我都会得到一个对话框,其中包含文本“当前位置没有可用的源代码。”:


For instance, stepping into the constructor of the following class would give me the above message:
例如,进入以下类的构造函数会给我上面的信息:
public class Test
{
    private Stack<String> _Dummy = new Stack<String>();
    public Test() { }
}
I assume this is because at some point I fiddled with the settings for the symbol server, but no matter what I fiddle with now, I can't seem to get rid of that message.
我认为这是因为在某些时候我摆弄了符号服务器的设置,但无论我现在摆弄什么,我似乎都无法摆脱该消息。
Where has my stupidity forgotten what it did?
我的愚蠢在哪里忘记了它做了什么?
Summary of my current options:
我目前的选择摘要:
- [ ] Enable address-level debugging
- [x] Enable Just My Code (Managed Only)
- [ ] Enable .NET framework source stepping
- [ ] Enable source server support
- Symbol file .pdb locations - empty
- Cache symbols from symbol servers to this directory: C:\temp (empty)
- [ ] 启用地址级调试
- [x] 仅启用我的代码(仅限托管)
- [] 启用 .NET 框架源步进
- [ ] 启用源服务器支持
- 符号文件 .pdb 位置 - 空
- 将符号服务器中的符号缓存到此目录:C:\temp(空)
采纳答案by JGurtz
See if some source files are accidentally excluded. Do properties of the solution and look at the Debug Source Files section under Common Properties.
查看是否意外排除了某些源文件。执行解决方案的属性并查看通用属性下的调试源文件部分。
回答by Keith Ketterer
In Solution Explorer, check your solution property page under Common Properties, Debug Source Files. If you see the assembly listed under "Do not look for these source files:", delete it and the issue should go away.
在解决方案资源管理器中,在Common Properties、Debug Source Files下检查您的解决方案属性页。如果您看到“不要查找这些源文件:”下列出的程序集,请将其删除,问题就会消失。
Open the solution property page
打开解决方案属性页


Check "Do not look for these source files"
勾选“不要查找这些源文件”


回答by Shilpa Silk
If you do not want to debug .NET assembly, a quick fix to avoid "No source available to current location" problem is to uncheck "Require source files to exactly match the original version" check-box under Tool -> Options -> Debugging -> General
如果您不想调试 .NET 程序集,避免“当前位置无可用源”问题的快速解决方法是取消选中“工具”->“选项”->“调试”下的“需要源文件与原始版本完全匹配”复选框-> 一般
回答by Erwin Mayer
If you don't want this annoying tab to appear, you can try this add-on that I created: http://erwinmayer.com/labs/visual-studio-2010-extension-disable-no-source-available-tab/
如果你不想出现这个烦人的标签,你可以试试我创建的这个插件:http: //erwinmayer.com/labs/visual-studio-2010-extension-disable-no-source-available-tab /
It is directly downloadable on the Visual Studio Gallery: http://visualstudiogallery.msdn.microsoft.com/en-us/fdbb2036-471e-40a7-b20e-31f8fd5578fa
它可以直接在 Visual Studio Gallery 上下载:http: //visualstudiogallery.msdn.microsoft.com/en-us/fdbb2036-471e-40a7-b20e-31f8fd5578fa
回答by Joe
Here's what I did to solve this problem. First, stop debugging and just have your solution open in VS. Next, make sure your solution config is set to Debug as opposed to Release. Then simply do a Rebuild (not Build, Rebuild). The next time you fire up the debugger, it should function as normal and you shouldn't get that error message.
这是我为解决此问题所做的工作。首先,停止调试并在 VS 中打开您的解决方案。接下来,确保您的解决方案配置设置为调试而不是发布。然后简单地进行重建(不是构建,重建)。下次启动调试器时,它应该会正常运行,并且不会收到该错误消息。
Hope this helps!
希望这可以帮助!
回答by psur
I had the same problem in an unmanaged C++ program: when debugger was in mainfunction it always showed "No source code available" and, what was interesting, other functions in this file was shown without problems. In this case, the problem was that I allocated too much data on the stack. After reducing it, the debugger started to work without problems.
我在非托管 C++ 程序中遇到了同样的问题:当调试器在main运行时,它总是显示“没有可用的源代码”,有趣的是,这个文件中的其他函数显示没有问题。在这种情况下,问题是我在堆栈上分配了太多数据。减少它后,调试器开始正常工作。
It was in Visual Studio 2010.
它在 Visual Studio 2010 中。
回答by Ali Ers?z
Check if your projects have a project reference, not a DLL reference! If there exists a DLL reference, your changes will not be recognized by your referenced project, and you will get an error message like yours.
检查您的项目是否有项目引用,而不是 DLL 引用!如果存在 DLL 引用,则引用的项目将无法识别您的更改,并且您将收到与您类似的错误消息。
回答by Musawwir Ali
This error made me go crazy as well. I was using 'AjaxControlToolkit' and had referenced it using 'Add Reference' to my project.
这个错误也让我发疯了。我正在使用“AjaxControlToolkit”并使用“添加引用”将它引用到我的项目中。
I deleted the 'AjaxControlToolkit' reference and added the same with 'Add Existing Item' and after that I had no problems at all...
我删除了“AjaxControlToolkit”引用并添加了“添加现有项目”,之后我完全没有问题......
回答by Peter Mortensen
One way, that also works for Express Editions of Visual Studio (say, Visual Basic 2005 Express Edition), is to rename the .suofile. It is in the same folder as the solution file, .sln. Exit Visual Studio before renaming the file.
一种也适用于 Visual Studio Express Edition(例如 Visual Basic 2005 Express Edition)的方法是重命名.suo文件。它与解决方案文件位于同一文件夹中.sln。在重命名文件之前退出 Visual Studio。


The .suofile contains non-critical settings, like window positions, etc. However, it also contains all the breakpoints which is why it is probably better to rename it than delete it in case this action is regretted.
该.suo文件包含非关键设置,如窗口位置等。然而,它也包含所有断点,这就是为什么重命名它比删除它更好,以防万一这个操作后悔。
回答by curiousBoy
This is how I solved it.
我就是这样解决的。
Right click your project -> Properties - > Compile -> Advanced Compile Options...
右键单击您的项目 -> 属性 -> 编译 -> 高级编译选项...
Then Set 'Generate debug info' to 'Full' from the drop down menu.
然后从下拉菜单中将“生成调试信息”设置为“完整”。
Hope that helps.
希望有帮助。

