Can I use .NET 4.0 API calls on .NET 2.0? - c#

If I make .NET 4.0 API calls and the customer only has .NET 2.0 installed, will my EXE work? I assume no -- absolutely not. But I want to reconfirm and point this out to my client yes/no.
Background... I'm from the Linux/PHP world. My client uses a Windows C# app on the frontend, and Linux/PHP on the backend. He's asked me to investigate this issue.

The .NET 2.0 runtime will error out on you when trying to run anything written and compiled with .NET 4.0, the reverse is not true.

Application code targeted against the .NET 4.0 framework will not run in an environment that only has the .NET 2.0 framework installed.
See "Version Compatibility" section here:
http://msdn.microsoft.com/en-us/library/8477k21c.aspx

What you can do is have your .NET 2 code access the .NET 4 libraries via a web service. If you were to expose the .NET 4 API via a web service, it would be agnostic of the .NET version and the technology between them all together.

Related

Activator.GetObject for .netstandard

everybody!
I have a piece of code which calls win service remotely with Activator.GetObject(type, url). But the project is targeting .net framework and we're going to migrate to .net standard. The later, though, does not provide such behavior.
Is there a way to do the same action in .net standard?

Is ASP.NET Core 2.0 the technology which is implemented in both frameworks (.Net Framework and .NET Core)?

I want to create an ASP.NET Core MVC 2 web application which I could host on Linux and Windows (i.e. in both OS). So, I am to use .Net Core. But when I create new ASP.NET Core MVC 2 web application I see two comboboxes. At first I am to select either .NET Frmework or .NET Core. The second combobox contains only ASP.NET Core 2.0.
Q1:
Does it mean that ASP.NET Core 2.0 is technology which is implemented in both frameworks (.Net Framework and .NET Core)?
It is impossible to switch .Net Framework to .NET Core for such project later. I could use .NET Core but here Microsoft writes that I am to use .NET Framework if I want to use Windows Service...
I want to use Nginx for Windows on my computer (instead of IIS) - it is interesting for me to try it. :) Here Microsoft describes how to host ASP.NET Core web application on Linux with NGinx. At the article the Create the service file topic exists. But it is for Linux... So, if I want to host my ASP.NET Core MVC 2 web application on Nginx in Windows then I am forced to use Windows Services (look here). But in the Host an ASP.NET Core app in a Windows Service article Microsoft writes that I am to use .NET Framework instead of .NET Core...
Q2
Does it mean that I can't the same project use for build my web application for Linux and Windows (for Windows Service)? Does it mean that for my goal I am to create two project: for .NET Framework and for .NET Core and to share the code sources for both projects?
Q1
Does it mean that ASP.NET Core 2.0 is technology which is implemented
in both frameworks (.Net Framework and .NET Core)?
.NET Core 2.0 and .NET Framework 4.6.1 are both implementations of .NET Standard 2.0. What this means is that they can both do the same things, and work mostly the same, but .NET Framework contains some Windows only libraries (System libraries such as Windows Forms) that mean it can only run on Windows. .Net Core programs can run on Windows, Linux and MacOS.
It is impossible to switch .Net Framework to .NET Core for such
project later. I could use .NET Core but here Microsoft writes that I
am to use .NET Framework if I want to use Windows Service...
While this is technically possible, you really want to avoid it. It's a huge headache, and usually breaks a lot of your code, with missing dependancies etc.
I want to use Nginx for Windows on my computer (instead of IIS) - it
is interesting for me to try it. :) Here Microsoft describes how to
host ASP.NET Core web application on Linux with NGinx. At the article
the Create the service file topic exists. But it is for Linux... So,
if I want to host my ASP.NET Core MVC 2 web application on Nginx in
Windows then I am forced to use Windows Services (look here). But in
the Host an ASP.NET Core app in a Windows Service article Microsoft
writes that I am to use .NET Framework instead of .NET Core...
I haven't personally used NGinx for Windows, but it looks as though they want you to set the target version for your NET Core app to NET Framework for the purposes of their example. Since .NET Core doesn't have the references to System specific libraries, you can easily change target to NET Framework. This doesn't make it a NET Framework project, it just changes the runtime against which Visual Studio will build it.
Q2
Does it mean that I can't the same project use for build my web
application for Linux and Windows (for Windows Service)? Does it mean
that for my goal I am to create two project: for .NET Framework and
for .NET Core and to share the code sources for both projects?
You can absolutely use the same application for both platforms, however it'll be a little different to how you're used to it. Since .NET Core is platform agnostic, Visual Studio won't generate an exe for you, it'll just generate dll files. You then use the dotnet command at the command line to start the program, e.g.
dotnet helloWorld.dll
This is how you run the program on any OS, provided you have the .NET Core runtime installed (There are plenty of guides on how to do this online).
Hope I've answered everything clearly :)

Targeting .NET Core vs .NET Standard

We've a server side "classic" WCF .NET application running on Windows. We added last year Linux support using Mono and a Web-Api replacement of WCF.
Checking the compatibility with the Api-Port tool, we found that the we would need much few changes targeting directly .NET Core instead of .NET Standard.
So for server side application like ours, that will be running only on Windows and Linux, is it correct to say that does not make any sense to target .NET Standard?
For server-side applications targeting .NET Core is enough.
There is a detailed answer here: What is the difference between .NET Core and .NET Standard Class Library project types?

.NET Remoting migrating from 2.0 to 4.0 .NET version

Stuck with a legacy web app that has its entire Biz & Data logic inside a .NET Remoting project.
Web project runs in 4.0, however Remoting layer is under 2.0.
Trying to see if its possible to migrate those DLL's to .NET 4.0 to simplify deployment process and remove the need to have 2 separate application pools.
Is this possible ?
According MSDN "legacy technology that is retained for backward compatibility with existing applications and is not recommended for new development." - so I'm assuming the namespaces should still be present in 4.0.
Yes, this is possible. The remoting stuff still works fine in .NET 4.0.

Deploying a .net 4.0 application

I have an application built with .net 4.0 and uses WPF
My users have Windows 7 with default .net 3.5 installed.
My application cannot be downgraded to .net 3.5 and I want to avoid users from going through the process of downloading and installing .net 4.0 which is about 40MB (Even with silent install).
Since my application is a small one, is there a way to deploy it with only the required .net 4.0 libraries? and thus avoiding the installation of the entire .net 4.0 framework
If this is not possible, is there a way to execute the .net 4.0 app in a .net 3.5 environment?
If this is not possible, is there a way to execute the .net 4.0 app in a .net 3.5 environment?
No. Basically you really need to get the environments aligned. You say your application cannot be downgraded to .NET 3.5 - presumably that's because you're using something which is specific to .NET 4.0. It stands to reason that you can't then execute that in an environment which doesn't have .NET 4.0.
You need to decide which is more painful - changing your app to target .NET 3.5, or asking your users to install .NET 4.0.

Categories

Resources