An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module"

Viewed 9238

I'm developing a C# application and I get the following error at debug runtime:

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module. Could not load file or assembly 'System.Runtime, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

And the application goes to the break mode.

I'm new in C# and .NET world. I'm using the Visual Studio for debugging.

3 Answers

I had this exact error message earlier. I do not know if our situations are the same, but hopefully, they are, and this fix works for you as well.

So I am also new to c#, and especially visual studio. So, when I opened my project, I would launch visual studio, click open folder, and open the folder my application was in. But alas, I did not know that in fact to open it, you open up the folder in explorer, and double click on the .sln file. If you do that, when you build and/or debug the application, you will not get that error. Or at least if your circumstances are the same as mine.

May I ask, when you open it up, how do you do so? If it is any other way then searching for the .sln in file explorer and double clicking on it, then that is your problem.

I am also new in C#, and I had the same msg when I tried to open my app written in VSC in VS2019. I created this app using dotNet. The one possible answer is you can run the app using the Open Developer Command Prompt and you can type dotnet run. The app will run automatically.

Related