Mixing .NET 3.5 with 4/4.5 assemblies in the same

2019-07-20 17:25发布

问题:

I have a solution that most projects are compiled in .net 4.5 (I use async and tasks).
There are couple of projects that need to be compiled in .net 3.5 since they use SDK that support only .net 3.5.
If my "Common" project is compiled in 4.5, and I have a project with target framework 3.5 that needs it, Is it possible to add reference to the Common ? (e.g my logger interface is at Common and i get it with DI).

Thanks.

Output:

could not be resolved because it was built against the ".NETFramework,Version=v4.5" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v3.5".

回答1:

As the compiler tells you, it is not possible. You can try to split your "Common" library into two parts, one built for 4.5 and another for 3.5 framework.