What kind of class library works with both Universal and Winform projects?

假装没事ソ 提交于 2019-12-23 18:59:16

问题


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.

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?

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


回答1:


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:

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.



来源:https://stackoverflow.com/questions/35850623/what-kind-of-class-library-works-with-both-universal-and-winform-projects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!