Cannot access types of .NET Standard Library

848 views Asked by At

I created in VS2017 two C# projects:

  • .NET Standard 1.5 library
  • .NET Framework 4.6.2 Console application. (implements Standard 1.5)

I added the reference to the library, but cannot access types from it.
Compiler just complains that it cannot find neither namespace nor class.

Moreover, Studio allows to start the application and then throws:

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

So, what am I doing wrong?

1

There are 1 answers

1
Lex Li On BEST ANSWER

You have to add NETStandard.Library to your reference list of the traditional project. Then all related assemblies would appear in your output folder so that runtime exceptions won't occur. (If you do need anything more than .NET Standard Library, also add that package to this traditional project).

At this stage, it is a limitation we have to get used to. Ultimately Microsoft should find a better way to address it.

(Note that you might also need assembly redirection in app.config, if there are version number mismatch.)