whats the solution of error .
targets ‘net6.0’. It cannot be referenced by a project that targets ‘.NETFramework,Version=v4.8.1’
Please provide more info like screen shots of exact and complete message.
Overall .NET Framework and .NET Core (which .NET 6 belongs to) are incompatible.
You can add references of the same framework or .NET Standard in both.
I did a quick demo code.
.NET Framework app
It is a .NET Framework console app.
I wrote 3 class libraries respectively with .NET Framework, .NET Standard and .NET (Core).
The 2 First will work perfectly.
The 3rd won’t even be allowed by IntelliSense (In VS).
namespace DotNetFConsole
{
internal class Program
{
static void Main(string[] args)
{
//DotNetFHelloWorld.DotNetFClass.HelloWorldFromDotNetFramework();
//DotNetSHelloWorld.DotNetSClass.HelloWorldFromDotNetStandard();
DotNetHelloWorld.DotNetClass.HelloWorldFromDotNet();
}
}
}
But if you force it and try to compile
.NET 6 app
Works on that direction
I must admit I am a bit surprised because .NET Framework code should not work AFAIK. Maybe this code is too simple to cause any issue.
Or stated another way, there is a compatibility layer that can handle such simple code.
Hope this helps at least understand your problem.