简体   繁体   中英

How to add .NET dll reference to UWP project?

I have several .NET dll projects for .NETv4.x. I changed version to 4.6.1 and rebuilded without problems. When I try to add referene to them from my UWP project I get error:

The project targets '.NETCore' while the file reference targets '.NETFramework'. This is not a supported scenario.

I can't also reference .NET projects from 'Add reference...'->'Projects':

Unable to add a reference to project

But in project settings I can't see anything to change it's target to '.NETCore'. Is it possible to reference .NET4.x project from UWP project or convert it to UWP project type?

UWP project can reference Universal Windows Class Library, Portable Library or Windows Runtime Component. Your classic .NET projects are none of those.

If you're planning to continue to develop and use those libraries in both classic .NET projects and UWP, I suggest you try Portable Library in which you can choose target platforms, but beware that this approach can be somewhat limiting because it takes lowest common denominator for available namespaces and classes.

Another approach would be to create two different projects targeting classic .NET and UWP, and share the code between them either adding files as links or using Shared Project. Then resolve all problems with conditional compilation, build them and use appropriate output .dll's for both cases.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM