Is Dependency Injection part of the WinUI architecture? - dependency-injection

Dependency Injection has been baked into the .NET 6 Web application architecture. I know I can add bits and pieces of DI from Microsoft.Extensions.DependencyInjection package to build a WinUI application, but I'm wondering if something more integrated to the new architecture is available.

Is Dependency Injection part of the WinUI architecture?
No. WinUI is not an "architecture". It's a native (and in version 3 completely decoupled) UI platform component for Windows.
Having that said, you can of course implement dependency injection in your WinUI apps but there is no equivlent of the Microsoft.Extensions.DependencyInjection package included in the Windows App SDK.

Related

.Net Core Vs .Net framework to create a new mvc web application

I have visual studio 2015 professional editton, and i want to create my first MVC web application which should be a .net core. now i am watching an online learning demo, which mentioned to create this project:-
while inside my visual studio i have these options:-
so which option i need to chose?
second question, how i can be sure that i am using the latest version of MVC?
Thanks
First, there is no such thing as MVC 6. It's ASP.NET Core. Second, the decision of whether to use .NET Core or .NET Framework comes down to what you need to do. .NET Core is cross-platform (Windows, Mac and Linux), whereas .NET Framework is Windows-only. .NET Core is also lighter weight, faster, and has a number of new CLR features, compared to .NET Framework. Virtually the only reason to use .NET Framework is if you have a dependency on something that utilizes Windows-specific APIs, meaning it can't be run cross-platform. Otherwise, you should always use .NET Core, if you can get away with it.
ASP.NET Core is really just a collection of NuGet packages, and like other NuGet packages, they can be updated easily. However, the difference is that these NuGet packages are generally tied to a particular version of .NET Core, and thus, the appropriate version of the packages are installed based on which version of .NET Core you're targeting. For example, if you're targeting netcoreapp2.2 then you'll see that that packages like Microsoft.AspNetCore.App will be brought in with versions like 2.2.x.
So, to answer your question about staying up to date, it essentially entails installing the latest version of the .NET Core SDK, and then changing your project to target that new version. Then, all the ASP.NET Core NuGet packages will naturally update accordingly.

Install nuget package : EntityFramework 6 in .NETStandard 2.0 class library

I installed nuget package: EntityFramework 6 in .NET Standard2.0 Class library. On building the project I am getting the below warning message:
NU1701:Package 'EntityFramework 6.2.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.
Does it mean that we cannot use EntityFramework 6 in .NETStandard 2.0 class library?
Can anyone help me here by providing their inputs
[...]. This package may not be fully compatible with your project.
Entity Framework 6 will be compatible with a project that target .NET Framework but will not be compatible with a project that target .NET Core
The answer is yes, you can use EF6 with .NET Standard 2.0 class library as long as you plan to only support .NET Framework
Microsoft already announced they plan to release a version of EF6 that support .NET Core at the end of 2019.
Disclaimer: I'm the owner of the project Entity Framework Classic
Entity Framework Classic is an EF6 fork. It's everything you like about EF6, but with better performance, must-have features, .NET Core support, and more.
It's currently the only option available to use a EF6 fork on a project that target NET Core
There is a free Community version that includes pretty much everything and an Enterprise version that include additional features.

F# .NET Standard Library Project

I have a Xamarin Forms solution, containing several F# portable class libraries.
In order to use the latest version (4.0.0) of Microsoft.Azure.MobileClient, I need to upgrade to FSharp.Core 4.2.1, but this appears to be incompatible with Profile 78:
Could not install package 'FSharp.Core 4.2.1'. You are trying to
install this package into a project that targets
'.NETPortable,Version=v4.5,Profile=Profile78', but the package does
not contain any assembly references or content files that are
compatible with that framework. For more information, contact the
package author.
It is possible to use .NET Standard class libraries from Xamarin projects, but is it possible to create a .NET Standard class library in F#?
What is the best way forward here?
What the error message is telling you is that the project is targeting a PCL target. FSharp.Core 4.2.x does not have a PCL target anymore, and only contains .NET Framework and .NET Standard 1.6 binaries. Neither is compatible with the PCL target F# is using here.
The release notes for FSharp.Core were recently updated with developer guidance: https://www.nuget.org/packages/FSharp.Core/
This is the important bit for your project:
For existing packages targeting .NET Frameworks 4.0 or lower and PCLs, use FSharp.Core 4.1 or lower.
.NET Standard (as of this time) has not proliferated across all things .NET yet. As #Foole says, you can indeed create a .NET Standard class library with F# today. But it's not compatible with the rest of the .NET ecosystem until .NET Standard is fully supported on all flavors of .NET.
You can try to convert your Xamarin.Forms (and your F#) project from .NET Portable to .NET Standard 2.0, since both packages can be added to .NET Standard.
How to convert Xamarin.Forms to .NET Standard
Create new Xamarin.Forms project (skip for already created project)
Create new .NET Standard library project in the same solution
Add reference to Xamarin.Forms package
Copy your content from Xamarin.Forms shared project to the new library project
Change all references (from Android, iOS, UWP) to point to the library project instead of the shared project
Source: Xamarin Blog

Getting Started with Dependency Injection in Asp.Net Mvc 5.2.3

I'm having trouble getting started setting up dependency injection in my project.
Is there Microsoft provided functionality to do dependency injection with Mvc 5.2.3? If so where is it because I can't find it.
All the articles I can find are about the DI functionality in Core. According to Wikipedia that is the next version of Mvc. I'd rather just use what is built in to my version.
If nothing is built in, then I'll go do research myself on third party solutions.
There's no built-in DI functionality in ASP.NET MVC 5.2.3. You will need to use a third party DI container or write your own. If you are looking for one written by Microsoft you may checkout Unity.

Dependency Injection framework for Windows 8 metro apps

i can't seem to find a dependency injection framework for windows 8 metro apps.
Is there a framework for win8 metro apps?
Ninject is not yet support for win8 metro. So does anybody have a suggestion? (Castle, Spring, ...)
You could try Unity 3.0 for .NET4.5 Preview.
Here is the source for Ninject WinRT: https://github.com/remogloor/ninject
It just not yet released.
I've been using the Beta version of Autofac Portable Library (which is supported in Metro apps) and it is working great so far.
The Catel MVVM toolkit also contains a DI-container, it's metro version will be released this week (according to one of their developers): http://catel.codeplex.com

Resources