"MyClassLibraryProjectName" targets 'net5.0'. It cannot be referenced by a project that targets '.NETFramework,Version=v4.7.2'

23 Views Asked by At

I have added class library in my current project that have .NETFramework,Version=v4.7.2. I have other class library project that have targets 'net5.0. how can I reference library project to my current project.

my error

'..\demo.csproj' targets 'net5.0'. It cannot be referenced by a project that targets '.NETFramework,Version=v4.7.2'. demo1

I have tried with update framework runtime but it's not working.

1

There are 1 best solutions below

0
Bhavika Sardhara On

The thing is that version difference we can solve with 3 way Option 1 - We can change the target framework of .NET project. Steps : RC on Project. -> click on Property -> Application Tab -> Target Framework Dropdown -> Change this to 5.0 or latter version.

Option 2 - Create .NET Standard Class Library Common set of API available across different .NET plateform. Steps : Create new class Library Project(.NET Framework) -> Move your all code from class library project to here(new project). ->Solve reference errors -> Reload Project

Option 3 - also can change target framework from .csproj file of .NET Project

<TargetFrameworks>net5.0;netstandard2.0</TargetFrameworks>

My Error was solve with Option 2. Hope you find your solution.