Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

.net

coreclr

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
like image 770
ibocon Avatar asked Oct 13 '17 02:10

ibocon


People also ask

What C is used for?

C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...

What is C in C language?

What is C? C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system.

What is the full name of C?

In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.

Is C language easy?

C is a general-purpose language that most programmers learn before moving on to more complex languages. From Unix and Windows to Tic Tac Toe and Photoshop, several of the most commonly used applications today have been built on C. It is easy to learn because: A simple syntax with only 32 keywords.


2 Answers

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.

like image 73
Jan Kotas Avatar answered Sep 19 '22 14:09

Jan Kotas


The above answer helped me pin point my issue in my Test project.

My case: I was using a .netcore csproj targeting net45 and was missing the MSTest adapter reference.

Once I added these all was good.

 <ItemGroup>
    <PackageReference Include="MSTest.TestAdapter" Version="2.2.7" />
    <PackageReference Include="MSTest.TestFramework" Version="2.2.7" />
  </ItemGroup>
like image 26
dynamiclynk Avatar answered Sep 16 '22 14:09

dynamiclynk