简体   繁体   中英

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

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.

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.

The most important hint in the error message is that it's trying to load the System.Runtime assembly, which is part of .NET. The problem has come up before on Stack Overflow: Visual Studio 2017 - Could not load file or assembly 'System.Runtime, Version=4.1.0.0' or one of its dependencies

Consider those solutions first.

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.

This happens when you open the file folder. Open the solution file by double click on the.sln file in the file folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM