Previously .NET Native Toolchain was only available for Windows Store Apps and only for UWP applications. From what I've read about VS2017 with .NET Native 1.6 some or all of these restrictions may no longer to be in place but the information is a bit confusing, so:
Can I now use .Net native toolchain for an existing C# Desktop (non-Windows Store) application with Visual Studio 2017 (or earlier)?
Does the application have to use UWP or can it also be an existing WPF application?
If it cannot be WPF, could I still create a .Net Native non-GUI assembly that can then be used by a regular JIT WPF application? I suppose I would need to make sure that no reflection is used in either direction but I rather doubt this would be possible at all.
Can I now use .Net native toolchain for an existing C# Desktop (non-Windows Store) application with Visual Studio 2017 (or earlier)?
No, .NET Native applies to UWP apps only.
2) Does the application have to use UWP or can it also be an existing WPF application?
It has to be a UWP app. WPF does not support .NET Native.
3) If it cannot be WPF, could I still create a .Net Native non-GUI assembly that can then be used by a regular JIT WPF application?
No. WPF requires the full .NET Framework with all that it entails.
Related
I have a WPF application built for .Net Framework.
It references a UWP library for doing things like using Start-Tiles etc.
I'm now converting this WPF application to .Net 6, but can't seem to find a way to call UWP methods from it.
How can this be achieved?
An application that targets and runs on the .NET Framework cannot consume a library that is compiled for UWP, like for example a library that was created using the Class Library (Universal Windows) template in Visual Studio.
You may use Windows Runtime APIs in your .NET Framework app though but that's another thing.
If you want to share code between a .NET Framework application and a UWP app, your project that contains the shared code should target .NET Standard. It can then be consumed from all applications that target platforms that is compatible with the version of the .NET Standard you are targeting in your class library.
I can compile my application on Linux using mono mcs, but the result is an executable for .NET Framework 4.5. On windows it runs but I cannot use any newer functionality.
I tried to find out how to compile it with .NET SDK 5.0 but on Linux it seems to not include Windows Forms.
Is there a way to compile a forms application on Linux which uses at least .NET Core 2.0?
Windows Forms (and WPF) are both not supported on Linux with .NET Core and probably never will be. Winforms runs on mono, but that is based on .NET Framework, not .NET Core. The reason is mostly because the internal implementation of Windows Forms is actually an abstraction layer over the Windows GDI, and therefore a linux port would need to be a complete rewrite.
.NET 6.0 will bring a new GUI framework called maui, which is intended to bring real cross-platform experience to .NET. This is hopefully the last step to make .NET really cross platform, as it was actually designed 20 years ago. You can already try it out, as prerelease versions of .NET 6.0 are ready for download (go to https://aka.ms/dotnet-download).
You can develop WinForms and WPF UI applications using .Net Core. But these UI applications can run only on Windows. Only non-UI applications developed in .net core is truly cross-platform and can run on Windows, Linux and Mac OS.
The MAUI framework is yet to be officially released from Microsoft that allows UI applications to be cross-platform.
MAUI
If you switch from Windows Forms to UWP you can target the Windows, macOS and Linux platforms (as well as mobile) with a single visual studio solution. You just need to use the Uno platform
https://platform.uno/
I have built an (Windows Forms App) application on Windows in C#. Now, I would like to target this whole project / application to mac OS without changing the application. Is there any easy way to achieve it? I don't want to rebuild the entire app from scratch on MAC. I don't want to use virtual machine on MAC... I have Visual Stuido 2017 and a paired MAC. But, I'm lost here.
;TLDR Mono, using WinForms and MonoDevelop IDE for development.
.NET Framework is the full implementation that includes everything but runs only on Windows.
.NET Core is the newer OpenSource implementation of .Net framework but doesn't include WPF/WinForms - because those rely heavily on DirectX/GDI essentially making them Windows only.
Xamarin. Xamarin based off of Mono framework branched more towards iOS and Android. There is a Xamarin Mac but it supports the same GTK# based UI toolkit as Mono.There is a WinForms equivalent UI toolkit as well called Xamarin Forms but it is mobile only (iOS, Android & Universal Windows Platform)
Mono. Mono is OpenSource implementation of .Net framework, uses GTK# by default for UI. Does run fine on all of Windows, Linux, macOS. Uses GTK# as underlying UI toolkit on all OSes including Windows.
What's Cross Platform? There is a subset of Base Class Library, called .NET Standard Library - as well as the compilers platform, only these subsets of .Net are truly cross-platform.
To sum it up,
Mono does however support Windows Forms on both Linux & macOS.
Except some corner cases it works very well.
However the UI look and feel is Windows only. It is like running Windows applications under WINE. Default Mono IDE is MonoDevelop.
Xamarin Mac is great if you want to write a new application from scratch since Xamarin Mac exposes you full macOS SDK and offers its own IDE (Xamarin Studio).
In your situation though, Mono is best option. After having installed mono you can even try running your current app as mono appName from terminal. It should render the UI even if the paths and other resources are broken.
Update 2021
WPF and WinForms now are open source and part of .Net Core (which now is referred to as .Net. Core is dropped in name). The previous classic .Net is now called .Net framework. New WPF/WinForms features enhancements are on available for .Net only. Though these still are Windows only and will stay so.
Avalonia UI Framework and Uno Platform are newer .Net Core (AKA .Net) based cross-platform solutions. Both use XAML. Avalonia is more like WPF while Uno tries to be cross-platform UWP.
You have to use .NET Core (not .NET Framework) to run app properly on different OS than Windows.
Differences between platforms explained
I have a .dll that was written to target the .NET Framework. I need to create a Cordova plugin that can make calls to this .dll.
Our Cordova App runs on a Windows 10 Tablet.
Because this .dll targets .NET Framework and not .NetCORE, I cannot take the approach of a WinRT component that's suggested in all of the guidance I've seen.
Is it possible to have a Cordova plugin that makes calls to a .NET Framework .dll and if so can you recommend a correct approach?
Disclaimer: I'm in the weeds with Cordova. I'm learning as I go. An EXAMPLE would be overwhelmingly appreciated.
Thanks
No on both form and function. You'll need to use a .Net library that works with .Net Core for UWP.
Form:
Cordova apps on UWP run in the native JavaScript environment, not in a WebView hosted in a C# app. The only way for a UWP JavaScript app to call .Net functions is via a Windows Runtime Component (WRC).
While you could (in theory) write a version of Cordova for Windows Runtime that uses a .Net hosted WebView I'm not aware of any existing ones. (The Windows Phone 8 versions Hassan Ali linked do use a Silverlight WebBrowserControl, but don't run on Windows 10 tablets).
Function:
Even if you did change the Cordova host to .Net so it could call .Net directly without a WRC that would still run in the UWP context.
UWP apps can use only NetCore, not the full .Net Framework, whether they are direct .Net apps or call .Net inside a WRC.
Apache Cordova is a platform for building native mobile applications
using HTML, CSS and JavaScript
So no, you can't call .NET assemblies directly on the client. You have to put them in a plugin. You can find some samples for Windows Phone here. Another sample in this SO question.
I'm creating a library application that will act as a wrapper for an exposed API. This library ideally should work on any desktop application, but truth be told I'm intending to use this on the WP7 once I'm done creating the library.
Would this work?
From silverlight.net:
Silverlight is the application development platform for Windows Phone 7. High performance gaming is also supported through the XNA Framework.
You can't reference a .NET assembly which was compiled against the full .NET Framework in a Silverlight application.
Develop your library for Silverlight and all should be fine.