哪种 class 库适用于 Universal 和 Winform 项目?
What kind of class library works with both Universal and Winform projects?
在 visual Studio 2015 年,在我的解决方案中,我有一个逻辑层(class 库)项目添加到 WinForm 项目的引用中。
不,我要添加一个新的 Windows 通用项目并向其中添加相同的逻辑层(class 库)。
但是,visual studio 不允许我添加 class 库作为对通用应用程序的引用,我收到一条错误消息。
问题是,什么样的 class 库可以添加到 Universal 项目的引用以及具有相同解决方案的 Winform 项目?
更新:消息是"Enable to add a reference to project 'project-name' ."
您需要为 class 库项目使用 Class 库(便携式) 选择:
添加后,您必须选择目标平台:
为了能够将它与 WinForms 一起使用,select 与您在 WinForms 项目中 select 编辑的目标框架相匹配的 .NET 框架。如果您的 WinForms 以 .NET 4.5 为目标,请确保 select;如果将其更改为目标 .NET 4.6,则可以 select 将其作为可移植库的目标,等等。否则,您会收到一条错误消息:
Unable to add a reference to project 'Your library name'. The current
project's target is not one of or compatible with the targets of
Portable Library project 'Your library name'.
请注意,您可以稍后更改这些选项,方法是进入 Library 选项卡下的项目属性。
在 visual Studio 2015 年,在我的解决方案中,我有一个逻辑层(class 库)项目添加到 WinForm 项目的引用中。 不,我要添加一个新的 Windows 通用项目并向其中添加相同的逻辑层(class 库)。 但是,visual studio 不允许我添加 class 库作为对通用应用程序的引用,我收到一条错误消息。
问题是,什么样的 class 库可以添加到 Universal 项目的引用以及具有相同解决方案的 Winform 项目?
更新:消息是"Enable to add a reference to project 'project-name' ."
您需要为 class 库项目使用 Class 库(便携式) 选择:
添加后,您必须选择目标平台:
为了能够将它与 WinForms 一起使用,select 与您在 WinForms 项目中 select 编辑的目标框架相匹配的 .NET 框架。如果您的 WinForms 以 .NET 4.5 为目标,请确保 select;如果将其更改为目标 .NET 4.6,则可以 select 将其作为可移植库的目标,等等。否则,您会收到一条错误消息:
Unable to add a reference to project 'Your library name'. The current project's target is not one of or compatible with the targets of Portable Library project 'Your library name'.
请注意,您可以稍后更改这些选项,方法是进入 Library 选项卡下的项目属性。