Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Visual Studio ask for the source path after I get: "There is no source code available for the current location."

Sometimes, in debugging mode, I try to watch code at some level of the call stack, and I get an error:

There is no source code available for the current location.

I know what it means. If I know where the file is, how can I give the source file to Visual Studio?

The first time, it gives me a browse window for search, but at this time I didn't have the code. When I downloaded it from SVN and tried (after restart of the whole computer) to access the code again, I get the error.

Please don't explain me that Visual Studio can't find the file and because of it gives disassembly, I know it. I searched for the option to give it the file.

like image 601
rodnower Avatar asked May 18 '11 12:05

rodnower


People also ask

How do I add source code to Visual Studio?

You can open code into Visual Studio in the following ways: On the Visual Studio menu bar, choose File > Open > Folder, and then browse to the code location. On the context (right-click) menu of a folder containing code, choose the Open in Visual Studio command.

How do I change the source path in Visual Studio?

In Visual Studio, click Tools > Options. Expand Projects and Solutions and click Locations. The Projects location field defines the default location for storing new projects. You can change this path if you are using a different working folder.

Where is the source code in Visual Studio?

First, select DevTools > Settings > Experiments > Open source files in Visual Studio Code, and then re-start DevTools.

How do I attach Visual Studio to a process that is not started yet?

You can attach the Visual Studio debugger to a running process on a local or remote computer. After the process is running, select Debug > Attach to Process or press Ctrl+Alt+p in Visual Studio, and use the Attach to Process dialog to attach the debugger to the process.


2 Answers

In Visual Studio (at least since v.2005) you have to check the Solution properties:

In the Solution Explorer, right-click on the Solution -> Properties -> Common Properties -> Debug Source Files.

There is a list here: "Do not look for these source files:" - remove (all) entries from this list, then VS should ask you for the source path again.

Here's a screenshot from VS 2013 Express:

VS 2013 Debug Source Files - Settings

like image 191
Martin Ba Avatar answered Sep 25 '22 02:09

Martin Ba


None of the above steps worked correctly in VS 2013 for me.

After removing the incorrect source path from the Solution -> Properties -> Common Properties -> Debug Source Files list, closing all instances of Visual Studio, each time I ran and stepped into the code, I would see a file dialog would pop up and go away and then VS would step to the incorrect source location again.

After numerous attempts at this, I used a hex editor to do a Unicode string search and found the offending path was still in my solution's .suo file. Deleting that file still did not fix the problem.

Finally, I opened the solution again, went to the Solution -> Properties -> Common Properties -> Debug Source Files list and changed the incorrect source location to the correct one (i.e. instead of deleting it). I then Ctrl+Shift+S to save all, exited VS, started VS again and started a debug session. This time it stepped to the correct code.

So, if the above is not working for you, there's an issue in VS 2013 with it caching the path that prevents deletion from working and you must change the existing path.

like image 39
Nelno Avatar answered Sep 22 '22 02:09

Nelno