WPF and WinForms Will Run on .NET Core 3

WPF and WinForms Will Run on .NET Core 3

If you haven't had a chance to explore the new capabilities of .NET Core 3, read along with an expert in the framework to discover what it brings to the table.


Maybe you already heard or read about the fact that Microsoft brought WinForms and WPF to .NET Core 3.0. Maybe you already saw the presentations on the Connect conference, or any other conference or recording when Scott Hanselman shows how to run a pretty old WPF application on .NET Core. I saw a demo where he ran BabySmash on .NET Core.

BTW: My oldest son really loved that BabySmash when he was a baby.
WPF and WinForms on .NET Core?

I was really wondering about this step, even because I wrote an article for a German .NET magazine some months before where I mentioned that Microsoft won’t build a UI Stack for .NET Core. There were some other UI stacks built by the community. The most popular is Avalonia.

But this step makes sense anyway. Since the .NET Standards move the API of .NET Core more to the same level of the .NET framework, making the APIs almost equal was simply a question of time. WPF and WinForms are based on .NET Libraries, so it should run on .NET Core.


Does This Mean it Runs on Linux and Mac?

Nope! Since WinForms and WPF uses Windows only technology in the background, it cannot run on Linux or Mac. It is really dependent on Windows. The sense of running it on .NET Core is performance and to be independent of any framework. .NET Core is optimized for performance so you can run super fast web applications in the cloud. .NET Core is also independent of the installed framework on the machine. Just deploy the runtime together with your application.

You are now able to run fast and self-contained Windows desktop applications. That’s awesome, isn’t it!?


The .NET CLI

Every time I install a new version of the .NET Core runtime I try dotnet new and I was positively shocked about what I saw this time:

You are now able to create a Windows Form or a WPF application using the .NET CLI. This is cool. And I for sure needed to try it out:

dotnet new -n WpfTest -o WpfTest dotnet new -n WpfTest -o WpfTest 

And yes, it is working as you can see here in Visual Studio Code:

And this is the WinForms project in VS Code

Running dotnet run on the WPF project:

And again on the WinForms GUI:


IDE

Visual Studio Code isn’t the right editor for this kind of project. If you know XAML pretty well, it will work, but WinForms definitely won’t work well. You need to write the designer code manually and there isn’t any designer support yet. Maybe there will be some in the future, but I’m not sure.

The best choice to work with WinForms and WPF on .NET Core is Visual Studio 2017 or newer.


Last Words

I don’t think I will now start to write desktop apps on .NET Core 3, because I’m a web guy. But it is a really nice option to build apps like this on .NET Core.

BTW: Even EF 6 will work in .NET Core 3, which means you also don’t need to rewrite the database access part of your desktop application.

As I wrote, you can now use this super fast framework and the option to create self-contained apps. I would suggest you try it out and play around with it. Do you have an older desktop application based on WPF or WinForms? I would be curious about whether you can run it on .NET Core 3. Tell me how easy it was to get it running on .NET Core 3.


Learn More

The Complete ASP.NET MVC 5 Course

Build a Real-world App with ASP.NET Core and Angular 2 (4+)

ASP NET Core (ASP.NET 5),MVC 6,C#,Angular2 & EF Crash Course

Rest Api’s in Asp.Net and C#

Hands on ASP .Net Core 2

Originally published by Juergen Gutsch at https://dzone.com

Introduction to ASP.NET Core Tutorials | ASP.NET Training | Simpliv

Introduction to ASP.NET Core Tutorials | ASP.NET Training | Simpliv

This course is designed you give you a deep understanding of modern .NET concepts without confusing you or making you lost in the sea of .net technologies that keep springing up now and then. Get behind the modern .NET directions and grasp all that is going on nowadays in the world of .NET.

Description
Last years a great number of technologies came up to the world of .NET platform: nowadays we have the full (classic) .NET framework with CLR as a runtime, Mono with its own runtime, .NET Core with Core CLR, WinRT, UWP and Xamarin, a new JIT compiler RyuJit, .NET Standard, PCL, .Net Native, new Roslyncompiler with open API, NuGet based project management. God’s sake! It’s so simple to get lost in that ocean of technologies. You need to understand the overall picture to feel comfortable today. Didn’t you feel like a small fish in the ocean last time? Well, I did. I questioned myself, "what the hell is going on around me?" I didn’t quite understand the directions in which technologies develop. I didn’t know what to expect, what to learn next. In such situation, you feel helpless. And what we are going to do in the course is that we’re going to eliminate this nasty feeling of being helpless by learning all the most important notions in the modern .NET platform.

Teaching Approach

No fluff, no ranting, no beating the air. I esteem your time. The course material is succinct, yet comprehensive. All important concepts are covered. For absolute beginners, I offer my help on Skype absolutely free if requested. Don't forget that this course has English subtitles, so if you don't understand my accent, feel free to turn them on.

Take this course and you will be satisfied.

Build a deep understanding of modern .NET concepts

If you go behind the modern .NET directions, then this course is for you. This course will bring a whole picture of what's going on nowadays in the world of .NET, so you'll understand what you can and what you can't achieve using specific technologies. This course is like a navigation map.

Content and Overview

The goal of this course is to reveal the whole picture of the .NET world. One of the most profound technologies is the new .NET Core platform, so learning it, is a second primary goal of this course.

Of course, all the way along we will discuss all the other technologies I mentioned above.

This course is built for all kind of C# developers who are interested in learning the .NET platform. This course is beneficial for juniors as well as for seniors who want to stay well-informed about modern .NET platform. I’m sure any student will find something interesting and useful in this course.

The main prerequisite is to be familiar with development on the .NET platform in C#. That’s all you need.

In short, the course covers the following topics:

Classic .net platform, it’s building blocks, the history of this platform
Mono platform, it’s building blocks. You’ll figure out if classic .NET and Mono are compatible. We will compare classic .NET framework and Mono platform
.NET Core is the new cross-platform .NET platform. We will understand what’s different here comparing to other .NET platform and this platform means for the future of the .NET world platform
.NET Native is an interesting ahead-of-time compilation technology. You’ll know that a form of .NET Native comes to .NET Core as well.
Do you really understand what is UWP? How it is related to WinRT and what WinRT actually is?
Roslyn as a compiler platform
NuGet as a system of dependencies management
Installation of .NET Core
Command-Line Interface (CLI) of .NET Core
Deployment in .NET Core: SCD and FDD
The problem of cross-compiling
Portable Class Library (PCL)
.NET Standard
.NET Portability Analyzer
Unit-Testing in .NET Core
Upcoming Changes quick overview
How long is this course: The course is around 2 hours. All are video lectures. You will be able to download all the slides and code samples used in the course.

Keywords related to the course:

.NET Core
C#.NET Core
.NET Standard
NuGet
Core CLR
.NET Ecosystem
Who is the target audience?

Anyone from beginner to senior
Basic knowledge
Need to be familiar with development on the .NET platform in C#
What will you learn
Create, deploy and manage .NET Core applications
Disctinct different technologies: platforms, runtimes, compilers and so on
Create and use .NET Standard Libraries
Understand all the modern .NET concepts
Write unit-tests in .NET Core
To continue:

Supporting Windows Forms and WPF in .NET Core 3

Supporting Windows Forms and WPF in .NET Core 3

In this episode, Jeremy interviews Mike Harsh about some of the work being done and decisions being made to enable Windows Forms and WPF applications to run well on .NET Core 3.0 and beyond.

In this episode, Jeremy interviews Mike Harsh about some of the work being done and decisions being made to enable Windows Forms and WPF applications to run well on .NET Core 3.0 and beyond.

[04:20] - What was the motivation behind bring desktop workloads to .NET Core?

[10:42] - What was the biggest challenge with add support for desktop technologies?

[12:42] - How did the decision to open source Windows Forms and WPF come about?

[14:01] - How easy was it to open source Windows Forms and WPF?

[17:35] - What does the roadmap look like?

[20:45] - What does the future of Windows Forms look like?

Thanks for reading

If you liked this post, share it with all of your programming buddies!

Follow us on Facebook | Twitter

Further reading .NET Core

WPF and WinForms Will Run on .NET Core 3

How to Port Desktop Applications to .NET Core 3.0

Build amazing web apps with ASP.NET Core 3.0

Moving from Node.js to .NET Core

Building Single Page Application Using ASP.NET Core & Angular

How to send multipart/form-data to asp.net core web api?

I'm trying to send a image and textfields to a api endpont but i'm reciving "Unsupported content type 'multipart/form-data; boundary=---------------------------81801171514357" This is a ASP.NET Core 2.1 Web api.

I'm trying to send a image and textfields to a api endpont but i'm reciving "Unsupported content type 'multipart/form-data; boundary=---------------------------81801171514357" This is a ASP.NET Core 2.1 Web api.

I have this:

[HttpPost("/api/account"), Authorize]
public void SaveUser(UserModel info)

And my model:

    [JsonProperty(PropertyName = "avatar")]
    [DataType(DataType.Upload)]
    public IFormFile Avatar { get; set; }
[JsonProperty(PropertyName = "name")]
[DataType(DataType.Text)]
public string Name { get; set; }

Then i use axios:

    var formData = new FormData();
formData.append("avatar", imageFile);
formData.append("name", name);
axios.post("/api/account", formData);

I expected this method to run, not throw an exception. But how?

I have tried to add:

[Consumes("application/json", "multipart/form-data")]

But no success..

Then i tried:

[HttpPost("/api/account"), Authorize]
public void SaveUser([FromForm]UserModel info)

The method runs, but the properties is empty on info object :(