8
votes

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?

1

1 Answers

10
votes

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.