C# .NET Core How to debug System.IO.FileNotFoundException in System.Private.CoreLib.dll?

ibocon picture ibocon · Oct 13, 2017 · Viewed 11.9k times · Source

When I run .NET Core Web API Application on VS 2017,
In Output's Debug panel, keep showing me Exception throw:

'System.IO.FileNotFoundException' in System.Private.CoreLib.dll

However, application runs well without stoping or malfunctioning.
I know Exception always means somthing needs to be cared.

So, how can I search what File is Not Found when run CoreCLR?

------------- more -------------------

'dotnet.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App\2.0.0\System.Private.Xml.Linq.dll'. Symbols loaded.
'dotnet.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App\2.0.0\System.Private.Xml.dll'. Symbols loaded.
'dotnet.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App\2.0.0\System.Resources.ResourceManager.dll'. Symbols loaded.
Exception thrown: 'System.IO.FileNotFoundException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.FileNotFoundException' in System.Private.CoreLib.dll

Answer

Jan Kotas picture Jan Kotas · Oct 13, 2017

Go to Debug/Windows/Exception Settings and check FileNotFoundException under Common Language Runtime Exceptions. The debugger will stop when the exception is thrown and you will be able to see what is going on.

Note that it is not unusual for exceptions to be expected and handled in some cases. You may find that the exception is expected and handled, and nothing needs to be done to fix it.