Search code examples
c#visual-studioinheritancedllfilenotfoundexception

Creating dll files to be used in another project gives FIle Not Found Exception error C#


I created two dll files Person and Student. The Student class inherits from the Person class. I then created a Winforms file and added a reference to both the person and student dll files. I created an instance of Student and gave it some data which was supposed to be displayed in my GUI. once I run it however I get an error which says

System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.'

I'm using Visual Studio 2022 and .net Framework 4.7.2. can anyone pls help me with thisenter image description here


Solution

  • I was finally able to resolve it, turns out the class libraries I created weren't targeting .NET Framework But were targeting .NET Core. When I was creating my class library files, I selected the option for Class Library instead of Class Library(.NET Framework). Thanks for everyone who contributed