core icon indicating copy to clipboard operation
core copied to clipboard

Window example?

Open yhojann-cl opened this issue 10 years ago • 30 comments

There is an example to create a form.

using System;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DemoApplication
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }

    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
    }
}

The propject.son

{
    "version": "1.0.0-*",
    "compilationOptions": {
        "emitEntryPoint": true
    },

    "dependencies": {
        "Microsoft.NETCore.Runtime": "1.0.1-beta-*",
        "System.Runtime": "4.0.21-beta-*",
        "System.ComponentModel": "4.0.1-beta-*",
        "System.Threading.Tasks": "4.0.11-beta-*",
        "System.Windows.Forms": "4.0.0.0",
        "System.Data": "4.0.0.0",
        "System.Drawing": "4.0.0.0",
        "System.Text": "4.0.0.0"
    },

    "frameworks": {
        "dnxcore50": { }
    }
}

To restore, dependencies not found:

me@machine:~/dnet$ dotnet restore
Microsoft .NET Development Utility CoreClr-x64-1.0.0-rc1-16048

  CACHE https://api.nuget.org/v3/index.json
Restoring packages for /home/me/dnet/project.json
  CACHE https://api.nuget.org/v3-flatcontainer/microsoft.netcore.runtime/index.json
  CACHE https://api.nuget.org/v3-flatcontainer/system.runtime/index.json
  CACHE https://api.nuget.org/v3-flatcontainer/system.componentmodel/index.json
  CACHE https://api.nuget.org/v3-flatcontainer/system.threading.tasks/index.json
  GET https://api.nuget.org/v3-flatcontainer/system.windows.forms/index.json
  GET https://api.nuget.org/v3-flatcontainer/system.data/index.json
  GET https://api.nuget.org/v3-flatcontainer/system.drawing/index.json
  GET https://api.nuget.org/v3-flatcontainer/system.text/index.json
  NotFound https://api.nuget.org/v3-flatcontainer/system.data/index.json 1435ms
  NotFound https://api.nuget.org/v3-flatcontainer/system.text/index.json 1434ms
  NotFound https://api.nuget.org/v3-flatcontainer/system.drawing/index.json 1435ms
  NotFound https://api.nuget.org/v3-flatcontainer/system.windows.forms/index.json 1498ms
Unable to locate Dependency System.Data >= 4.0.0
Unable to locate Dependency System.Drawing >= 4.0.0
Unable to locate Dependency System.Windows.Forms >= 4.0.0
Unable to locate Dependency System.Text >= 4.0.0
Writing lock file /home/me/dnet/project.lock.json
Restore complete, 1999ms elapsed

NuGet Config files used:
    /home/me/.config/NuGet/NuGet.Config

Feeds used:
    https://api.nuget.org/v3-flatcontainer/

Errors in /home/whk/Escritorio/dnet/project.json
    Unable to locate Dependency System.Data >= 4.0.0
    Unable to locate Dependency System.Drawing >= 4.0.0
    Unable to locate Dependency System.Windows.Forms >= 4.0.0
    Unable to locate Dependency System.Text >= 4.0.0

yhojann-cl avatar Dec 26 '15 20:12 yhojann-cl

Basically those missing dependencies are actually missing. You can see what is in the repo here:

http://www.nuget.org/packages?q=Windows.Forms

Also, I don't think they're going to be porting Windows forms to this new system. I don't know if anything has been announced but I would imagine that some team in microsoft is working on it secretly right now.

justinmchase avatar Jan 07 '16 18:01 justinmchase

There are no plans to bring application platforms (winforms, wpf, etc) to .NET Core at this time. Closing out this issue. Thank you.

joshfree avatar Jul 13 '16 17:07 joshfree

This is a pretty serious oversight, IMO.

mwpowellhtx avatar Apr 13 '18 13:04 mwpowellhtx

The .NET Core team announced today that WPF support will be coming in .NET Core 3, but it appears it will not be cross platform:

Support for Windows desktop will be added as a set of “Windows Desktop Packs”, which will only work on Windows.

https://blogs.msdn.microsoft.com/dotnet/2018/05/07/net-core-3-and-support-for-windows-desktop-applications/

poiprotocol avatar May 07 '18 22:05 poiprotocol

Thanks for the link.

But I gotta say that seems like an epic fail. In the first paragraph it says "... and enjoy all the benefits that .NET Core has to offer."

Yet it's windows desktop only. I just don't get it. They need a cross platform desktop UI not a windows only one. If I wanted a windows only platform I'd just use actual .NET.

How many years will it take them to do the thing they should have done on day one? Craziness.

justinmchase avatar May 08 '18 00:05 justinmchase

If the .NET Core works 100% only on Windows, what is difference between .NET and .NET Core?, the .NET Core is Cross platform but the components works only on windows.

yhojann-cl avatar May 08 '18 00:05 yhojann-cl

WPF only? And then on Windows only? No WinForms? I tend to agree. Epic fail.

mwpowellhtx avatar May 08 '18 01:05 mwpowellhtx

@WHK102 .NET Core is cross platform I believe. It can run on windows, linux, osx. But what they're talking about is making some kind of windows only UI thing that will allow you to load .NET core libraries. So you could have some underlying shared components that run in both places but they would have to be UI-less. Like maybe some networking library. You'll be able to build your UI but pull in all the core libraries people are building and sharing.

This sounds ok but its really disappointing that they aren't going all the way and making the UI components also cross platform to osx and linux as well.

justinmchase avatar May 08 '18 22:05 justinmchase

@justinmchase @WHK102 Precisely.

I have to pause and recollect the motivation of this rabbit hole into which Microsoft dove. Wasn't it motivated by the divergence of web based stacks? That is to say, MVC versus WebAPI, request, response, server hosting, etc, etc? Likely that more than et cetera, I gather. Is that accurate?

Over promised deliveries and scope snafus notwithstanding, perhaps it is justified, or perhaps not; I can certainly appreciate needing to align otherwise divergences in a code base having experienced domain specific forks along these lines myself.

However, clearly their priorities did not include support for "desktop applications", never mind across platforms. But I'm happy to be proven incorrect in this case. Which kind of leaves a vast chunk of the Microsoft based developers hanging in a lurch.

mwpowellhtx avatar May 09 '18 12:05 mwpowellhtx

@mwpowellhtx I used to work for Microsoft but I no longer have have any special insider information. However, I can speculate and from my experience (purely my opinions below, not microsofts).

There is currently a tension between the younger teams who believe in and push open source and cross platform technologies and some of the older, bigger teams, especially the Windows team, who want to create Windows only platforms.

The older bigger teams have a lot of influence, top down, on the developer division and so they are able to exert pressure on bigger picture projects like this. In this case you can see that there is a desire for the existing windows only platforms to begin to adopt .NET core and so this is essentially their migration strategy. Its entirely possible that they, as stated earlier in this thread, have secret projects to create OSX and Linux UI platforms but I don't know if thats true but if I had to guess as of now I suspect they don't.

In my opinion, I guess its fine to do what they're doing but if I was Microsoft I would also be looking to build a non-XAML based cross platform UI system instead. If they have the resources to do both then I guess go for it but if not then I would scrap the windows only effort and focus on the cross platform one. I would also make the new cross platform UI to not be XAML based but look to make a superior technology. Evolve away from XML completely frankly. Because trying to give a lateral "upgrade" path for people already making windows only apps is not a real big market in my opinion. I think they should instead be looking to compete with Electron, as that is bleeding Microsoft platform technologies the most right now.

I do have one other insight to share and that has to do with the history of .NET, XAML and their relationship with Windows. Its interesting to note that XAML was originally created by shifting a lot of developer resources away from IE and onto the WPF team, this was why IE6 sat stagnant for a long time, the developers were gone! What they then made was the windows presentation foundation for what later became known as Longhorn, which ended up being a pretty large disaster. Longhorn largely failed because in they attempted to rewrite the windows shell using .NET and WPF. At the time (and still frankly) WPF had lots of really bad memory leaks, memory consumption issues, GC issues and a variety of other bugs and performance issues. This is why Longhorn was scrapped and what they ended up doing is to straight up reverting the Windows codebase back to several years to pre-longhorn and then subsequently worked overtime for another 3 years to crank out the gem known as Vista. Some people don't remember Vista fondly but frankly it was a hurculean effort and genuine evolution considering the prior turmoil that caused it. Or, it could have been worse.

So ever since Longhorn the Windows team has had an extremely bitter attitude towards .NET. I don't think its completely fair as they essentially went all in on a brand new technology and .NET has done a lot of evolving since then but nonetheless that sentiment remains among some of the now top players in Microsoft. So effectively there is a sentiment that some of the largest disasters in Microsoft history (IE's fall from grace and multiple "bad" versions of Windows) are, essentially, totally the fault of gambling on .NET and losing (from their perspective). And that sentiment can sometimes show in decisions like this.

So when Microsoft went to make their new metro apps for windows 8/10, they almost didn't even support XAML apps but only C++ and javascript. It was only the passion of the developer community that pushed it over the edge and let it in. I personally think that the .net developer community is the most vibrant and passionate one they have and if they were to create a cross platform desktop UI library it would spark a bit of a revolution. I mean right now everyone is moving towards Electron because, really, what else are you going to do? And while Electron is awesome there are some legit complaints and also there is some real complexity around native modules and such as well as some rendering performance limitations. Anyway the point is if they were to try to compete in that market they could legitimately make a dent, probably take over, and it would really be interesting to see.

Perhaps its a lack of vision, or perhaps they're actually doing it secretly right now but I suspect the truth is that the leadership, at some of the highest levels, is still stuck in the same mindset of windows desktop domination and it is prohibiting them from making correct decisions. I believe its likely that we will have to wait for some of the new guard to slowly take over before we can see these kinds of bold bigger moves.

justinmchase avatar May 09 '18 16:05 justinmchase

This is really strange behavior. Core evolved to be cross, universal. But Microsoft again disappointing a large community. What is the reason behind WinForm only for windows?

masums avatar May 10 '18 15:05 masums

The MS blog post provides some status and rationale. It really is worth reading in its entirety. But here is a key snippet:

Support for Windows desktop will be added as a set of “Windows Desktop Packs”, which will only work on Windows. .NET Core isn’t changing architecturally with this new version. We’ll continue to offer a great cross-platform product, focused on the cloud. We have lots of improvements planned for those scenarios that we’ll share later.

From a 1000-meter view, you can think of WPF as a rich layer over DirectX and Windows Forms as thinner layer over GDI Plus. WPF and Windows Forms do a great job of exposing and exercising much of the desktop application functionality in Windows. It’s the C# code in Windows Forms and WPF that we’ll include as a set of libraries with .NET Core 3. Windows functionality, like GDI Plus and DirectX, will remain in Windows.

poiprotocol avatar May 10 '18 16:05 poiprotocol

@poiprotocol Well, this is at least semi-not bad news, if it's accurate, and we don't see more scheduling snafus. .NET Core/Standard is what now? 2.1? 2.2? By at least "conventional" versioning standards. The natural next question is, "when"?

mwpowellhtx avatar May 10 '18 21:05 mwpowellhtx

I would question the decision to even support wpf, winforms etc. .NET Core is awesome, dont screw things up by adding things like wpf. If you consider desktop client support I would go for creating a new option (not anything like wpf) and make it cross platform!

uffebjorklund avatar May 10 '18 21:05 uffebjorklund

Yeah, well, don't screw things up by not providing any sort of migration path for WinForms, WPF, etc.

mwpowellhtx avatar May 10 '18 22:05 mwpowellhtx

There is a lot of misunderstanding here, and among desktop .Net developers at large. Developers have a vision - wave a magic wand and my WPF code will run everywhere. But this is not thought through at all.

Of course when they crated a cross-platform .Net runtime, it could not include Windows-specific bits. This is called .Net Core.

Of course they are allowing .Net Core in WPF. It doesn't make sense to maintain multiple versions of .Net. .Net Core is better than the .Net Framework already. They just need to take out the Windows-specific elements and put it in a separate library for use in WPF.

Of course .Net Core is not going to have GUI components built in, let alone the whole of WPF. Many of the systems it must run on don't even have GUIs.

Of course WPF is windows-only. Any operating system has to have a UI framework. A cross platform framework would be built on top of WPF or UWP.

You can take WPF and emulate it on other platforms. But: 1. It is technically hard. 2. It is only be feasible on desktop platforms, so only allows you to run on 7% more systems (mainly macs). 3. The results would not be great on those systems. This is not a project that deserves serious investment.

The right approach:

  1. Allow .Net code to run on all platforms, desktop and mobile (.Net Core and mono, eventually just .Net Core), and create UIs on each platform (WPF/UWP/Xamarin.Mac/Xamarin.iOS/Xamarin.Android). This is mostly done already in case you had not noticed.
  2. Create an abstraction layer for people who want to do the UI code once. This is also mostly done already, by Xamarin.Forms, although desktop support is more recent and so is not at the same level as mobile support.

So if you want cross-platform .Net apps for mobile or desktop, follow Xamarin. If you want to create cross-platform apps for desktop only using platform-independent abstractions, contribute to Xamarin.Forms by using it, testing it, and writing and extending components for it.

charlesroddie avatar May 19 '18 21:05 charlesroddie

@charlesroddie To clarify a few expectations.

  • let's assume WinForms/WPF can incorporate Core/Standard bits. Fair enough; targeting what runtime(s)? Framework 4.6.2, for instance? Could be. But I think what most folks, including myself, perhaps badly informed, are expecting, is a Core/Standard comprehension.

  • you are also assuming calls for a WinForms/WPF port into "native" Standard/Core, so to speak, is to the exclusion of other delivery modes, i.e. console applications, services, etc. I cannot speak for others, but that assertion is utterly FALSE, on EVERY level.

  • I don't know how you can say that many systems do not have GUI's. GUIs are indeed dominant across most platforms in the desktop world. Even most modern *nix platforms have SOME sort of GUI comprehension, when you take into consideration Linux flavors, Ubuntu, Mint, etc. So, this is not a tall expectation by any means. Even if it is a shim to something like Gtk, Qt, or whatever. Make SOMETHING happen toward these ends.

  • some of us might like to run a GUI cross-plat, but are not willing to buy into the Xamarin cost of doing business.

Still, epic fail, IMO. Planning is in the wind, discussion concerning v2.2 of Core/Standard. With a weak promise of WinForms/WPF comprehension coming in, let's say, v3.x, to be accurate. Until it happens, this will continue to be the criticism, at least for my part.

mwpowellhtx avatar May 19 '18 23:05 mwpowellhtx

@mwpowellhtx let's assume WinForms/WPF can incorporate Core/Standard bits. Fair enough; targeting what runtime(s)? Framework 4.6.2, for instance?

You will in future be able to use WPF targeting .Net Core as a runtime instead of .Net Framework. You can already use .Net Standard libraries. Both runtimes support .Net Standard 2.0.

you are also assuming calls for a WinForms/WPF port into "native" Standard/Core, so to speak, is to the exclusion of other delivery modes... GUIs are indeed dominant across most platforms in the desktop world.

.Net core does/will run across mobile devices and desktops, which have UIs, and servers, most of which don't. It would be similarly crazy to put "send a text message" inside .Net core as it would be to put "display a ribbon" in there.

some of us might like to run a GUI cross-plat, but are not willing to buy into the Xamarin cost of doing business.

Of course I would be happy to see an approach with lower costs. I assume this refers to performance or reliability? Unfortunately the community commentary about what Microsoft should do instead has not come up with a better approach, and has just ignored the serious problems posed by the current multitude of operating systems and platform types, expecting some sort of magic.

With a weak promise of WinForms/WPF comprehension coming in, let's say, v3.x, to be accurate. Until it happens, this will continue to be the criticism, at least for my part.

The ability of WPF projects to use .Net Core has very little relationship to cross platform development. It's a convenience for WPF developers, who can take advantage of developments and performance improvements in .Net Core, and for Microsoft which can stop developing .Net Framework and focus on .Net Core.

charlesroddie avatar May 19 '18 23:05 charlesroddie

@charlesroddie Good points. It will be interesting to see how it goes.

mwpowellhtx avatar May 20 '18 01:05 mwpowellhtx

Listen, its completely within the realm and resources of Microsoft to make a cross-platform desktop UI system. GitHub made one for crying out loud, called Electron. Video game makers do it over and over again all the time as well. Its not really that hard to do, frankly.

You make an abstraction over OpenGL and DirectX like every game engine ever made and layer a logical UI system over it. .NET core is already cross platform and that is the real hard part, adding in an graphics library is not really that bad. Heck, they could probably just use SDL and boom-done it.

Lets be clear here, the reason why they're still dinking around with Windows only UI platforms is because the upper management is still holding onto a fantasy that developers will voluntarily lock themselves into Windows by adopting them. Meanwhile marketshare continues to dwindle. Making a good .NET based cross platform desktop UI is what developers want, its what they've been wanting and needing for the past 10 years. This is, however, at odds with Microsoft upper level strategy. And that is because their upper level strategists are dinosaurs still holding onto the glory years and too busy fighting each other. That's what it all really boils down to.

Xamarin and XAML were fine experiments. They learned from it, that's fine, its time to evolve past it. Throw a team of game and tool makers together, don't be shackled to the past, make something actually good. It will pay off.

justinmchase avatar May 21 '18 14:05 justinmchase