Asp.net + JIT? - asp.net

What is default type of JIT compiler is used in .Net (visual studio)
out of (Pre-JIT,Econo-JIT,Normal-JIT)?

As far as I know default JIT is Pre-JIT but ASP.NET Does Not Support Pre-Just-In-Time (JIT) Compilation Through Native Image Generator.
A little bit of background on the various JIT types:
PRE-JIT: Compiles complete source code to native code in a single operation.
ECONO-JIT: Compiles only methods called at Runtime.
NORMAL-JIT: Compiles only methods called at Runtime and stored in cache.

Related

Is it possible to use SOS with a .NET7 AOT application?

When building a .NET Core AOT application the necessary CLR functionality is, if I understand it correctly, statically linked into the executable. That means that at run time, coreclr.dll is not present as a module and consequently SOS complains that it cannot find a suitable runtime module.
I've tried specifying the extension and CLR path. I can load SOS that way, but so far I haven't been able to run any of the SOS extension commands against an AOT application.
My assumption is that the application still uses the same internal structures such as the managed heap, so I am wondering how these can be debugged in a managed context using SOS (or something similar).

How to reduce size of winforms executable in .Net6?

I am very new to .Net6 and .Net Core in general. I understand that it is possible to publish a single file executable but I was a bit surprised to see that the executable is over 180MB even though the application is relatively small.
The application is targeted to Windows x64 only and uses Windows Forms. It has a handful of Forms and uses a JSON library and a CLI library.
There are a number of dependencies which were more-or-less added automatically but I don't know if they are all strictly necessary (e.g the ASPNetCore item)
Bearing in mind that I am only targeting Windows and the featureset used is limited, what are the actions I can take to reduce the size of the executable?
Update
I found https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/trim-self-contained which seems to indicate that 'trimming' of WinForms apps is not (yet) possible.
If you already did not, you may switch deployment mode to Framework-dependent from self-contained in publish profile settings, this will exclude .net runtime and will reduce file size dramatically.
However, excluding .net runtime, diverts from its purpose being single file, as you need to install correct runtime to use application. In my opinion, it is worth to keep single exe file with runtime included.
Use This code into your application.
<_SuppressWinFormsTrimError>true</_SuppressWinFormsTrimError>

What does 'CPU Specific Code' mean?

"When the managed code is compiled, the compiler converts the source code into a CPU independent intermediate language (IL) code. A Just in time compiler (JIT) compiles the IL code into native code, which is CPU specific" says here: http://www.tutorialspoint.com/asp.net/asp.net_introduction.htm
Please explain what 'CPU Specific' refers to.
It refers to native code that is specifically for the CPU it is currently running on.
According to MSFT docs:
JIT compilation converts MSIL to native code on demand at application run time, when the contents of an assembly are loaded and executed. Because the common language runtime supplies a JIT compiler for each supported CPU architecture, developers can build a set of MSIL assemblies that can be JIT-compiled and run on different computers with different machine architectures

How to reference an x86/x64/ARM class library (not an AnyCPU class library) in WinRT

In mvvmcross, I've got a plugin class library which references SQLite for WinRT.
Because of this, I can't build that class library as AnyCPU - instead, I have to reference it as x86, x64 or Any CPU.
This means that new client applications can't just reference a single DLL, but instead individual configurations must reference different input assemblies. Currently I'm doing this by manually editing the .csproj file using conditions.
However, this is a bit error prone (and a bit hard to explain!)
Is there any 'easy' way (1 click way) for client applications to reference the x86/x64/ARM class library trio so that MSBuild then picks the right version at runtime?
If your application does not rely on perfect performance, you might switch to C# SQLite, which is purely managed (Any CPU), so that your class libraries and executable can be set as Any CPU.
Alternatively, you might use Dependency Injection or MEF to inject the assemblies/types of correct bitness at runtime, and in this way at compile time you always work against an interface (which is bitness independent).
As far as I know, MSBuild cannot automatically handle bitness in the way you wanted.

Compiling code directly into MSIL

Is there a way to complie code directly into Native Code instead of MSIL so that we can bypass JIT while executing the code on machine. If its possible. Please let me know the technique also.
Thanks
Compiling MSIL to Native Code Ngen.exe
SUMMARY:
The runtime supplies another mode of
compilation called install-time code
generation. The install-time code
generation mode converts MSIL to
native code just as the regular JIT
compiler does, but it converts larger
units of code at a time, storing the
resulting native code for use when the
assembly is subsequently loaded and
run. When using install-time code
generation, the entire assembly that
is being installed is converted into
native code, taking into account what
is known about other assemblies that
are already installed.
Take look at - How to compile a .NET application to native code?
In the .NET languages I'm familiar with, the source is compiled directly to MSIL. What the JIT does is subsequently compile the IL code to native code.

Resources