20

I am debugging this code and getting a strange "source not found" page that is looking for this class called ExecutionContext.cs when the debugger lands on the Jtoken line.

ExecutionContext.cs not found.
You need to find the ExecutionContext.cs to view the source for the current call stack frame.

(see below for additional info)

using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using RestSharp;

IRestResponse content = myApi.GetSomething();
JToken token = JObject.Parse(content.ToString()); 
MyClass myclass = token.ToObject<Myclass>();

I've also tried replacing Jtoken with dynamic or var and same result. I've googled it and there is nothing but the MS documentation which was not helpful in fixing.

Any suggestions on how to get this to execute or at least throw a normal exception I can fix?

Thanks

Locating source for 'f:\dd\ndp\clr\src\BCL\system\threading\executioncontext.cs'. (No checksum.) The file 'f:\dd\ndp\clr\src\BCL\system\threading\executioncontext.cs' does not exist.

Looking in script documents for 'f:\dd\ndp\clr\src\BCL\system\threading\executioncontext.cs'...

Looking in the projects for 'f:\dd\ndp\clr\src\BCL\system\threading\executioncontext.cs'. The file was not found in a project. Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\'...

Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cvt\'...

Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\msclr\'...

Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\sys\'...

Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\thr\'...

Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\crt\src\'...

Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\crt\src\amd64\'...

Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\crt\src\arm\'...

Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\crt\src\concrt\'...

Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\crt\src\i386\'...

Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\crt\src\linkopts\'...

Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\crt\src\stl\'...

Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\crt\src\vccorlib\'...

Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\crt\src\vcruntime\'...

Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\src\mfc\'...

Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\src\atl\'...

Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\include\'...

The debug source files settings for the active solution indicate that the debugger will not ask the user to find the file: f:\dd\ndp\clr\src\BCL\system\threading\executioncontext.cs.
The debugger could not locate the source file 'f:\dd\ndp\clr\src\BCL\system\threading\executioncontext.cs'.

mskfisher
  • 3,291
  • 4
  • 35
  • 48
disq0
  • 801
  • 1
  • 6
  • 7
  • Are you sure that `content` is not null? – dbc Aug 15 '16 at 00:50
  • Well I did find that I was calling the wrong api, but when fixed, I still had the issue, however it also happened on a different line with a similar but different source not found error, looking for a Dictionary.cs file. Stopped, debugged again, and back to the first ExceptionContext.cs error. I just saw there is additional information in the error that was expandable, which I will include above. – disq0 Aug 15 '16 at 01:46

4 Answers4

50

A debug setting had been changed somehow and enabling the Just My Code setting returned it back to normal managed exception throwing. To do so, go to

Debug > Options... > Debugging > General > Enable Just My Code

scohe001
  • 15,110
  • 2
  • 31
  • 51
disq0
  • 801
  • 1
  • 6
  • 7
1

For me Just My Code was disabled, but this was because I had a different problem before where I could not debug any of my unit tests. It would go to run the test then exit for no apparent reason.

However, the reason, I found out, on closer inspection of the error referred to by OP, was that I was trying to debug in RELEASE mode! Once I changed to DEBUG mode it worked fine. I enabled Just My Code again after and it was still fine.

Kevin Dark
  • 458
  • 5
  • 15
0

Solution for MAC :

See the left top menu options on Visual Studio (2017), which display two items 1. Debug 2. Release . Just flip it to "Release" and that should resolve the issue. By mistake it switched to debug.

And clean your caches as well on Mac, you may follow below steps :

  1. Quit out of any actively open Mac apps
  2. Go to the Finder in Mac OS
  3. Hold down the SHIFT key (in Sierra) or OPTION / ALT key (Earlier) and pull down the “Go” menu in the Finder
  4. Choose “Library” from the Go menu options
  5. Once inside the Library folder, find and open the “Caches” folder
  6. Clear the caches
Mike ASP
  • 2,013
  • 2
  • 17
  • 24
0

for me, cleaning the solution and re-building worked

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 02 '21 at 22:10