0

I am developing on a Windows 11 machine and I have a .NET 6 Swagger WebApi solution that references .Net Framework 4.7.2 project (due to migration reasons it has to stay fw472).

I dockerized the api solution and deployed it into a Linux container locally on my machine. To my surprise I was able to browse the Swagger api and trigger a rest endpoint that uses the fw472 library which successfully returned the results.

My question is how does .Net 6 solution support using a .Net 472 class library when it is deployed into a Linux container?

doorman
  • 15,707
  • 22
  • 80
  • 145
  • Which base image are you using for your container? E.g. here are images which support .NET FW 4.7.2, provided by Microsoft: https://hub.docker.com/_/microsoft-dotnet-framework-runtime/ – Mike Mozhaev Jan 20 '23 at 17:34
  • Thanks for your suggestion. I think the reason this works is because .net6 allows calling fw472 but you need to make sure that the function you call uses only supported features from the .NET Core runtime assemblies. https://stackoverflow.com/questions/70005465/can-i-add-a-reference-to-a-net-framework-dll-from-a-net-6-project – doorman Jan 20 '23 at 18:06
  • 1
    .NET 6 is a multi-platform version of .NET, and it includes support for running on Linux. When you deploy a .NET 6 application, it includes the runtime for the specific platform it is deployed on. In the case of a Linux container, the .NET 6 runtime for Linux is included, and it can run both .NET 6 code as well as .NET 4.7.2 code, as long as the code is compatible with the Linux environment. This is because .NET 6 runtime is backward compatible with .NET Framework 4.x. – Gaurav Moolani Jan 21 '23 at 01:31

0 Answers0