什么样的类库适用于 Universal 和 Winform 项目? [英] What kind of class library works with both Universal and Winform projects?

查看:24
本文介绍了什么样的类库适用于 Universal 和 Winform 项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Visual Studio 2015 中,在我的解决方案中,我将一个逻辑层(类库)项目添加到 WinForm 项目的引用中.不,我要添加一个新的 Windows Universal 项目,并在其中添加相同的逻辑层(类库).但是,visual studio 不允许我添加类库作为对通用应用程序的引用,我收到一条错误消息.

In visual Studio 2015, in my solution, I have a Logic tier (class library) project that is added to the references of a WinForm project. No, I am going to add a new Windows Universal project and added the same logic tier (class library) into it. However, visual studio doesn't allow me to add the class library as a reference to the universal app, I get an error message.

问题是,什么样的类库可以添加到通用项目的引用以及同一个解决方案的Winform项目中?

The question is, What kind of class library that can be added to the references of Universal project as well as to the Winform projects withen the same solution?

更新:消息是启用添加对项目 'project-name' 的引用."

Update: the message is "Enable to add a reference to project 'project-name' ."

推荐答案

您需要为类库项目使用类库(可移植)选项:

You need to use the Class Library (Portable) choice for the class library project:

添加后,您必须选择目标平台:

Once you add that, you'll have to pick your target platforms:

为了能够与 WinForms 一起使用,请选择与您在 WinForms 项目中选择的目标框架匹配的 .NET 框架.如果您的 WinForms 面向 .NET 4.5,请确保选择它;如果将其更改为面向 .NET 4.6,则可以选择它作为可移植库的目标,依此类推.否则,您会收到一条错误消息:

To be able to use it with WinForms, select the .NET framework matching the target framework you have selected in your WinForms project. If your WinForms targets .NET 4.5, make sure you select that; if you changed it to target .NET 4.6, you are able to select that as the target for your portable library, and so on. Otherwise, you'll get an error saying:

无法添加对项目您的库名称"的引用.目前项目的目标不是目标之一或与目标不兼容便携式图书馆项目您的图书馆名称".

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

请注意,您可以稍后通过进入选项卡下的项目属性来更改这些选项.

Note that you can change these options later, by going into project properties, under Library tab.

这篇关于什么样的类库适用于 Universal 和 Winform 项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆