3

If you write a C# or F# program that runs on .NET Core, will the same bytecode also run on .NET (with no .NET Core installed)?

I have heard that reflection works differently, but it's not clear to me if those differences are part of the API.

MWB
  • 11,740
  • 6
  • 46
  • 91
  • Some basic brochure stuff: https://code.visualstudio.com/docs/runtimes/dotnet – Shannon Holsinger Sep 02 '16 at 23:46
  • 2
    @ShannonHolsinger: That page doesn't really answer the question. It says you can run the same code on different operating systems under .net core, but nothing of .net framework. – recursive Sep 02 '16 at 23:49
  • Okay how about http://stackoverflow.com/questions/37719061/c-sharp-f-interop-support-in-visual-studio-2015-on-net-core – Shannon Holsinger Sep 02 '16 at 23:52
  • 2
    @ShannonHolsinger: That is about interoperability between two different languages in the same runtime. This question is about compatibility for a single language at a time across two different runtimes. – recursive Sep 02 '16 at 23:53
  • @MaxB: There as an api portability analyzer here. https://github.com/Microsoft/dotnet-apiport You can use it to analyze a codebase targeting .net framework to see what parts can't transfer to core. – recursive Sep 02 '16 at 23:54
  • 2
    Binary-wise, BCL-wise or language-wise? – tia Sep 03 '16 at 03:07

1 Answers1

6

In .NET Core 1.0 there are new possibilities like being able to run your app on top of the .NET Core Platform or on top of the traditional .NET Framework 4.5.x. Environment setup depends on type of application (portable or self-contained app) and target frameworks.

From .NET Core Application Deployment documentation:

You can deploy your .NET Core app in either of two ways:

  • As a portable app. A portable app relies on a shared system-wide version of .NET Core to be present on the target system. Because .NET Core is already present, your app is portable between installations of .NET Core. Your app contains only its own code and any third-party dependencies that are outside of the .NET Core libraries. Portable applications are .dll files that can be launched by using the dotnet utility from the command line. For example, dotnet app.dll runs a portable application named app.

  • As a self-contained application. Unlike a portable app, a self-contained app does not rely on any shared components to be present on the target system. All components, including both .NET Core libraries and the .NET Core runtime, are included with the application and are isolated from other .NET Core applications. Self-contained applications include an executable (such as app.exe on Windows platforms for a self-contained application named app), which is a renamed version of the platform-specific .NET Core host, and a .dll file (such as app.dll), which is the actual application.

Regarding frameworks specifying (read more here)

  • The “framework” section in project.json specifies the framework or list of frameworks supported by your app.

  • The “imports” section in project.json is a way to use packages/libraries that are not based on the same version than your target Core platform version, such as “dnxcore” and portable-* libs, as shown below in one of the examples. It is important to use “imports” only for versions of .NET Core and PCL (Portable Class Libraries). Using it with TFMS from the traditional .NET Framework can cause issues or malfunction.

  • When supporting multiple frameworks in your app, you can selectively run your app on top of one or the other framework by selecting that default framework from Visual Studio or from the command line (as explained below).

Community
  • 1
  • 1
Set
  • 47,577
  • 22
  • 132
  • 150