Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the effect of setting (or not) .NET CLR version in ASP.Net Core?

What is the point of setting "No Managed Code" .NET CLR version for an IIS Asp.NET Core application pool?

No Managed Code for .NET CLR version

Documentation says that

ASP.NET Core runs in a separate process and manages the runtime. ASP.NET Core doesn't rely on loading the desktop CLR. Setting the .NET CLR version to No Managed Code is optional.

Since it is optional, what are the drawbacks of keeping the default v4.0? Why the documentation explicitly instructs to set it to "No Managed Code"? It's not very clear whether there are performance concerns around this particular configuration.

like image 394
natenho Avatar asked Mar 09 '18 02:03

natenho


People also ask

What is .NET CLR version?

The Common Language Runtime (CLR), the virtual machine component of Microsoft . NET Framework, manages the execution of . NET programs. Just-in-time compilation converts the managed code (compiled intermediate language code) into machine instructions which are then executed on the CPU of the computer.

Does .NET Core use the CLR?

Core CLR. The Common Language Runtime for . NET 5 (and . NET Core) and later versions.

Why common language runtime is important?

The CLR allows an instance of a class written in one language to call a method of a class written in another language. It also provides garbage collecting (returning unneeded memory to the computer), exception handling and debugging services.

Is .NET Core unmanaged?

NET, Framework is known as unmanaged code. Applications that do not run under the control of the CLR are said to be unmanaged, and certain languages such as C++ can be used to write such applications, which, for example, access low - level functions of the operating system.


1 Answers

When you specify .NET CLR version as 4.0 for an application pool, IIS loads into its worker processes some ASP.NET supporting libraries (like aspnet_isapi.dll for classic pipeline mode, and webengine4.dll for integrated mode). Such increases memory usage and attack surface, and might also have other impact.

Therefore, if you only run non-ASP.NET 4.x apps (PHP, ASP.NET Core and so on), you can set "No Managed Code" to remove all the troubles.

like image 94
Lex Li Avatar answered Oct 10 '22 02:10

Lex Li