Relationship between Universal Windows App and .NET Framework version - c#

In Visual Studio 2015, in the New Project dialog box, above the "Blank App (Universal Windows)" template name there is a combo box where you can select the .NET Framework version.
By default .NET Framework version 4.5.2 is selected, and most screenshots in tutorials and guides show this version as selected. However, there is also .NET Framework 4.6 in the list that can be selected.
What would be the difference if I select .NET Framework 4.6? Can I use any new APIs and/or any C# language improvements in an Universal Windows App?
And will the app only run on Windows systems that have the .NET Framework 4.6 installed?

And will the app only run on Windows systems that have the .NET Framework 4.6 installed?
No, it runs on any machine or device that's capable of running Universal apps. The framework version number detail disappears once the Store packages your app, the framework methods you actually use are compiled into the package. Done by .NET Native, the ahead-of-time compiler for Universal apps. The package even runs on a device that doesn't have the .NET Framework installed at all, like a phone.
So the framework you select doesn't matter. Picking 4.5.1 or 4.5.2 or 4.6 doesn't give you extra capabilities, those runtime revisions had very few new api additions in the first place. But above all you build your project with reference assemblies that doesn't expose them. Note how you can pick 3.5 in the combobox and it makes no difference.
Review Project > Properties > Application tab. That's what really matters, you target a Universal version. Currently only build 10240 so nothing to fret about, yet. The framework version that targets is a subset of the .NET Framework you have on your machine, named .NETCore. It is a lot smaller than the full version.
Don't forget to test your Release build, very important to .NET Native.

Related

Visual Studio mac 2019 (Community) - PresentationCore - Assembly not found for .Net Framework 4

I'm working on an existing solution at work that was written in C# targeting .NET Framework 4 in Visual Studio 2019 for Windows. I'm attempting to open the project on my MacBook Pro (running Catalina 10.15.6 if that's relevant) in Visual Studio Mac 2019 Community (Version 8.7.7 Build 10) so I can keep working on this remotely.
I'm noticing that a usage of System.Windows.Media isn't being found. My understanding is that this relies on PresentationCore, which I believe is included in .NET Framework 4. Sure enough, in the project's References, PresentationCore has a red "x" next, with alt text telling me "Assembly not found for framework .NET Framework 4".
Is there any way to add this? Is this just something not supported in macOS? I'm happy to provide any additional information.
You are trying to run a WPF application, which targets .Net Framework (4), on MacOS.
MacOS doesn't support WPF, or any version of .Net Framework, as .Net Framework is Windows-dependent1.
Image source: https://visualstudio.microsoft.com/vs/mac/
.Net Core is supported - that's the cross-platform version of .Net, which works on Windows, Mac, and Linux.
You'll need to do a migration to make it work with Core. Of course, this still won't allow you use to run WPF on a Mac, you'd need to use another cross-platform supported UI framework.
1 Of course, Mono is the open-source version of .Net Framework that runs on Mac and Linux, so you can also try that as an option if you're feeling adventurous or can't migrate to Core.
See also: Can you install and run apps built on the .NET framework on a Mac?
Gunr2171 is correct; but you could also look at running a virtual box on your Mac for a windows environment then use VS Code.
For a VM I recommend
https://www.virtualbox.org/wiki/Mac%20OS%20X%20build%20instructions
Then Windows 10 OS:
https://www.microsoft.com/en-ca/software-download/windows10ISO
Just an idea if Mono doesn't work for you.

Can you launch a app C# so it doesn't need the .NET and you don't downgrade the .NET version

I asked this before but if i downgrade to .NET 3.5 I am not able to do some things with the windows form application I get errors because some things that have been added in later versions are not in the version that I am using.
I am making the application for Windows 7.
Link to previous: Can you launch a app C# so it doesn't need the .NET
As C# is essentialy a human-readable version of .NET's intermediate language (IL) you cannot run an application created using C# without .NET runtime installed.
You don't need to downgrade anything - just change target version to 3.5. However, you'll have to stick to features of 3.5 and below in that case.
If you want to use 4.0+ - just make an installer for your app which installs .NET 4.0 runtime alongside.
P.S.
I personally really doubt that there is noticable count of boxes running Windows 7 without at least .NET 4.0.
Just include the required Framework for your application in the Installer. They should be able to run side-by-side.

running C# application on PC without having .net framework

I prepared a C# application that reads from registry and saves result in a simple notepad file. I tried to run it on another PC that doesn't have .net Framework. It gave initialization error because of not having .net Framework. The problem is that I can't install .net framework on that PC which has Win XP. Is there any way that I can run this application without having .net framework??
Please help as I need it urgently>>>....
Latest windows OS is normally packed with a default .Net Framework. Windows XP is packed with
XP
NET v1.0 Service pack 1
NET v2.0 -- Service packs 2 & 3
If it's not necessary for you to use latest version of .net Framework then you could change the target .Net Framework of your application[Go to Project Properties > Application > Target framework] to lowest version that default OS version has then you should be able to run your program without installing latest .net framework.
Pack .NET DLLs with the application.
In reference section set copy on build.
Right click on reference (e.g. System.Web) and press F4. Rest is pretty self-explainatory.

.Net 4.0 targeting on windows 8.x

I'm a bit confused about targeting .net 4.0 app to run on windows 8.x. In my understanding, windows 8.0 comes with 4.5 and windows 8.1 comes with 4.5.1. So my question, if I build a WinForms or WPF client app targeting c#/.net 4.0 (in Visual Studio Project settings) and of course only using .net 4.0 features (i.e, no features from .net 4.5.x), then will this app run fine on windows 8.x without having install .net 4.0 framework (that is, only relying on what comes installed with OS)? Basically, I'm trying to avoid forcing end user to install .net 4.0 framework on their machine before running the app.
Looking at DLLs properties of various Microsoft DLLs (e.g., System) they show same runtime version when targeting either .net 4.0 or .net 4.5.x --> v4.0.30319. So my understanding here is that 4.0 and 4.5.x are targeting same clr runtime version So, my .net 4.0 app should run fine???
From ref here (http://msdn.microsoft.com/en-us/library/bb822049%28v=vs.110%29.aspx), it says .net 4.0 can't even be installed on win8.x.
In my tests, targeting .net 4.0 and running on clean install of win8.1 seems to work fine (without having to install anything else) but looking for advice on gotchas.
Thanks.
Note that the .NET framework is intrinsically backwards compatible - .NET 4.5 will execute .NET 4.0 code just fine. This can be seen even within a solution in that a .NET 4.5/4.5.1 project can reference an older .NET project without incident. This includes .NET 4.0, as well as earlier versions.
In addition to the backwards compatibility, .NET 4.5 does run on the CLR 4.0 - 4.5 is simply a library and compiler expansion.
Possible gotchas
This emphasis on backwards compatibility is why we almost never see functions disappear from the .NET Framework, just get marked [Obsolete]. it's a good idea to check if any functions you use have become Obsolete, though this is rare and such functions usually continue to work as expected.
Windows 8 does NOT like Drive mapping, and will demand that you use UNC paths if you application touches any networks drives.
Windows 8 can be far more aggressive with requiring Admin privileges to run, up to and including needing to explicitly start VS as admin when trying to compile a program which outputs to C:\Program Files\...
Final note: ALWAYS test your application on the targeted platform before releasing to users.
Per this question:
.NET Framework 4.5 was released on 15 August 2012., a set of new or improved features were added into this version. The .NET Framework 4.5 is only supported on Windows Vista or later. The .NET Framework 4.5 uses Common Language Runtime 4.0, with some additional runtime features.
I would say then that by virtue of having .NET 4.5 installed you will also always have .NET 4.0 installed. I don't think this should be an issue then!
From the link you posted:
Each new version of the .NET Framework retains features from the previous versions and adds new features.
Also from that link:
The .NET Framework 4.5 is an in-place update that replaces the .NET Framework 4 on your computer, and similiarly, the .NET Framework 4.5.1 4.5.2, and 4.6 Preview are in-place updates to the .NET Framework 4.5, which means that they use the same runtime version, but the assembly versions are updated and include new types and members.
So, if a system has 4.5, it will be able to run apps targeted for 4.0 as well. The fact that some versions cannot be installed most likely only means that they are already included from the start.

Create a standalone exe without the need to install .NET framework

I'm a student and at the moment i'm doing an internship at a company. This internship is about analysing a project. For this project I have made a demo to show to the Marketing director. The demo I have made is a simple project created in Visual Studio 2010 in c# with Windows Forms and a connection to an Access database.
So now i have to show this demo to this director in a presentation but after this presentation the director wants the project on his computer so he can try and use it. The problem is now that the computers here in this company don't have .NET framework 4.0 and the computers are so protected over here that we can't install anything new. To install something you have to go through a procedure that takes weeks.
I have looked al over the internet but all i find is how to install the .NET framework.
Is there any possible way that I can create an standalone exe without the need to install .NET framework? Please help!
If you want to execute an application that is developed using Net Framework 4, you will need to have installed .Net Framework 4 on client computer.
Your application is compiled in CIL (Common Intermediate Language), so it needs to be interpreted by the framework engine.
It is the same if you want to execute a Java program. You will have to install the Java Machine.
The only way you don't need to install frameworks is programming native applications with C, C++.
C# now supports this with .NET Native.
Instead of compiling to intermediate language, it will compile to native code and run with statically linked .NET libraries. Therefore, there will be no .Net Runtime requirements for end-users.
https://msdn.microsoft.com/en-us/vstudio/dn642499.aspx
https://msdn.microsoft.com/en-us/library/dn584397(v=vs.110).aspx
Only works for Windows 10
You can't build a C# executable without .NET Framework. Even if some resources indicate that you can, that only works in theory.
But you could use an older version of .NET Framework like .NET 4.0. If this doesn't work for you, you have to choose a language like C++ which doesn't require CLR at all.
Update 2018:
Do not target .NET 2.0 or 3.5. It's not compatible with the 4.x version. However, .NET 4.0 targeted binaries work with .NET Framework 4.0, 4.5, 4.6, 4.7 and so on. So to reach maximum compatibility, compile with .NET 4.0. You will have to accept that some features will not be available, however, your binary will run virtually anywhere.
(2018: By now, .NET 2.0 - 3.5 has much lower distribution than 4.x)
Delphi is your solution, deploy native bin executables
YES, THIS IS POSSIBLE!
At least 3 ways exist:
1.you can check all OSes that you planning to run your app and build with such version of .NET. As Windows have a built-in framework libs.
Vista -.NET v3.0 -- All service packs
Windows 7 - .NET v3.5 -- All versions and service packs
Windows 8 - .NET v4.0 [Best choice if you are not sure]
Windows 8.1 - .Net v4.5
Windows 10 - .Net v4.6
as they are already pre-installed by default -- no extra install will be needed.
2.For windows 10 you can compile it into native code (but not into CIL) with ".NET Native". This is means that there are no .Net Framework will be needed for apps.
3.There is Turbo Studio (earlier Spoon and earlier XenoCode) that can wrap everything that your app needs and runs it in as a standalone.
From their site:
Turbo Studio
Run .NET Without .NET. Easily embed runtime dependencies such as .NET, Java, and SQL directly into virtual applications. Launch reliably on any desktop, regardless of underlying component installs.
You can use Mono and statically link you program, so your program don't need .NET CLR runtime and act as standalone program.
Mono Project
In more modern versions of .NET such as 5 and 6 and even with releases of .NET Core it had become a supported scenario to produce what is referred to as a single-file executable as well as a self-contained application.
As I understand it, these technologies take place of and build upon some of the capabilities that had been in the Mono development stack for a while now. Typically I've seen this feature used for applications which would be deployed to servers such as web sites and microservices however it could be used for scenarios such as the one that the original poster illustrates.
Using the .NET SDK publishing (producing the executable) for a single-file executable can be done using a command as the one below which comes directly from the documentation.
dotnet publish -r win-x64 -p:PublishSingleFile=true --self-contained true
For more details see Single file deployment and executable in the Microsoft .NET documentation site.
To be honest, it really isnt a problem nowadays. the .NET framework is found on almost every single computer nowadays, and you can even make a installer with Advanced Installer that silently install the .NET framework on your computer when you are installing the programme.

Categories

Resources