Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add .NET dll reference to UWP project?

Tags:

c#

.net

uwp

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?

like image 870
EvilCore2Duo Avatar asked Jun 12 '16 19:06

EvilCore2Duo


People also ask

Does UWP use .NET framework?

NET Standard is supported in which UWP versions. If you are developing a Desktop app, see instead . NET Framework versions and dependencies for detailed information on .

How do I add a reference to a project in Visual Studio?

You can also right-click the project node and select Add > Project Reference. If you see a References node in Solution Explorer, you can use the right-click context menu to choose Add Reference. Or, right-click the project node and select Add > Reference.


1 Answers

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.

like image 149
Andrei Ashikhmin Avatar answered Oct 04 '22 07:10

Andrei Ashikhmin