Can a console app make use of UWP assemblies? - .net-core

Can a .NET Core console app make use of classes in UWP assemblies?
I am only interested in those that do not involve visual elements.

No, a .NET Core app cannot directly reference an assembly that targets the Universal Windows Platform (UWP, uap10.0) if that's what you are asking.
So if you for example have a class library that was created using the Class Library (Universal Windows) template in Visual Studio, this project is not compatible with any other platform than UWP and cannot be referenced from a .NET Core app/project.
If you need to share code between UWP and other platforms, such as .NET Core, your class library should target .NET Standard instead of UWP.

Related

Xamarin Forms portable class library project

why can't I choose PCL project in options when I create a Cross-Platform App (Xamarin.Forms) ? there is just a Shared Project and .NET Standard, when I previously create a project there was a PCL option.
https://i.imgur.com/KDwty6a.png
When I try to create a PCL in VS 2017 it says "Class Library (Legacy Portable)
and "This project type has been deprecated. You should use Class library (.NET Standard) instead."
But if you still want it, xamarin has a guide, you can read about creating a PCL project here.

Why mix .Net Standard and .Net Core projects in one solution?

I just started working through the Apress "Building Web Applications with Visual Studio 2017". I am at the beginning setting up the projects.
So I set up a solution called SpyStore.
Then a .Net Core console app called SpyStore.DAL.
Then a .Net Standard Class Library project called SpyStore.Models.
My question is why would the author choose .Net Standard class library over .Net Core Class library. Is there a difference?
What is the difference between .Net Standard and .Net Core.
And could there be a reason for him mixing Standard in all of the sudden?
You can visualize .netstandard as a set of APIs. It is implemented by multiple runtimes, like netframework (net461, net47 monikers for example) or netcore (netcoreapp) A lib is not an executable, so it is independent from the concrete implementation.
Because you may want to use your library in a .net framework project (or any other implementation of .net standard), targeting netstandard make sure it is fully portable to any of these implementation, where a netcoreapp lib would only be targetable from a netcoreapp project.
An app can only be netcoreapp or netcore, as it is dependent of the implementation of the framework
You can find more infos here, and which platform implements which version of netstandard:
https://learn.microsoft.com/dotnet/standard/net-standard

Best class library project for ASP.NET Core v1.1?

Well, I know the ASP.NET Core v1.1 is fresh, but I am little playing a with it and I am a bit confused about the right class library project choosing in the solution. So here is a scenario:
I start in the Visual Studio 2017 with ASP.NET Core web application project template and choose sub-branch ASP.NET Core (= not with .NET Framework).
Ok, than I would like to add a class library project, but there are two possibilities:
.NET Core Library
.NET Standard Library
Well, ASP.NET Core v1.0 did not support common class libraries, but it seems v1.1 have no problem with that. So result is, I can reference both types.
So my question - is it ok to reference .NET Standard Library to ASP.NET Core project? Or should I reference .NET Core Library only?
You can use .NET Standard Library with .Net Core 1.0. The Standard library is trying to set a common API for the cross platform .net APIs.
You could use it in your project to get experience with it, but choose what makes sense for your class requirements and timeline.
This site has a good article on .NET Standard Library

Does MEF support UWP projects?

i have been searching on whether UWP projects can be implemented with Managed Extensibility Framework.
On the GitHub depository
of Prism, it says
MEF is supported with WPF for compatibility with previous versions.
It will not be added to Windows 10 UWP or Xamarin Forms.
(It is for Prism.Mef. But, can it not be for MEF generally?)
on Microsoft Developer Network it is said:
MEF is an integral part of the .NET Framework 4, and is available wherever the .NET Framework is used. You can use MEF in your client applications, whether they use Windows Forms, WPF, or any other technology, or in server applications that use ASP.NET.
Is UWP included in "any other technology" part or with the "in server applications that use ASP.NET" part?
I know .NET Core is used for UWP applications, but that ASP.NET part confuses me.
Briefly,is it possible to write UWP applications with MEF? Answers with sources will be appreciated. Thanks.
It is for Prism.Mef. But, can it not be for MEF generally?
For Prism.Mef only
Is UWP included in "any other technology" part or with the "in server applications that use ASP.NET" part?
UWP is included in "any other technology" part
Briefly,is it possible to write UWP applications with MEF?
Yes, by using the Microsoft.Composition NuGet package, we can easily integrate MEF in UWP app.
Here is an article for Windows Store app(8.1), it is similar with UWP app.
And this is a UWP MEF sample: Link

Class library that can be shared between .NET Framework and .NET Core

I have a big class library written in .NET 4.0 but when I reference it in a Store App that uses .NET Core, it shows an error. And further, Microsoft just released .NET Core for the next version of .NET.
I want to know what type of project will be able to be shared by both .NET 4.6 and .NET Core? Is a class library able to do that?
It seems that the release of .NET Core specialized for Store Apps causes confusion for me.
If you have a PCL (Portable Class Library) that works for Metro apps, it will definitely run on the fully fledged .NET (aka, your normal ASP.NET, WF, WPF applications).
That means that you don't have to do anything, besides porting your existing library to be compatible with the PCL you choose.
There is a new target called dotnet which you can use to target the platforms DNX, UWP and .Net 4.6. Effectively, this libraries are build against .Net Core packaged libraries instead of the libraries of the full .Net Framework.
Read more here: https://oren.codes/2015/07/29/targeting-net-core/ and related posts.

Resources