混合.NET 3.5与4 / 4.5组件在同一个解决方案/项目组件、解决方案、项目、在同一个

2023-09-05 04:03:34 作者:若世界了无遮拦

我有,大多数项目在.NET 4.5(我使用异步和任务)都编制了解决方案。照片 有几个需要在.NET 3.5编译,因为它们使用只支持.NET 3.5 SDK的项目。 如果我的共同项目被编译在4.5和我有一个目标框架3.5,需要它,是否有可能添加引用一个共同的项目? (例如,我的记录器接口是常见的,我得到它与DI)。

感谢。

输出:

 无法得到解决,因为它是建立在对.NETFramework,版本= V4.5的框架。这是一个更高的版本比当前目标框架.NETFramework,版本= 3.5版。
 

解决方案

由于编译器会告诉你,那是不可能的。您可以尝试你的公共图书馆分为两个部分,一个专为4.5,另一个为3.5框架。

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".

解决方案

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.