ASP.NET Interview Questions-6 :👈 👉:ASP.NET-Interview-Questions-7

.NET Core Native AOT Interview questions.

Common Interview Questions and Answers

Q1. What is Native AOT in .NET?

Native AOT is a compilation technology that converts .NET application code into native machine code before deployment, so the application does not require JIT compilation at runtime.

Q2. What is the difference between JIT and AOT?

JIT compiles code into native machine instructions at runtime. AOT compiles code into native machine instructions before deployment.

Q3. Does Native AOT require the .NET runtime?

A Native AOT executable does not require a separately installed .NET runtime. It still depends on the operating-system libraries and native components required by the executable.

Q4. Why are Minimal APIs recommended for Native AOT?

Minimal APIs support AOT-friendly application patterns and can use source-generated JSON serialization. They can reduce dependency on reflection-heavy features.

Q5. Why is reflection a problem in Native AOT?

Native AOT relies on compile-time analysis to determine which code and metadata are needed. Dynamic reflection can access types that the compiler cannot identify automatically.

Q6. What is source-generated JSON serialization?

It is a System.Text.Json feature that generates serialization metadata during compilation instead of relying on runtime reflection for type discovery.

Q7. What is trimming?

Trimming removes code and metadata that static analysis determines are not required. It helps reduce the size of the final application, but dynamically accessed code may need to be preserved explicitly.

Q8. Does Native AOT always improve performance?

No. It often improves startup time and can reduce memory overhead in some workloads, but throughput and overall performance depend on the application and must be measured.

Q9. Can Entity Framework Core be used with Native AOT?

Yes, for supported scenarios. Use compatible EF Core versions and providers, review AOT warnings, and follow the documented requirements for compiled models and queries.

Q10. What is the difference between Native AOT and ReadyToRun?

ReadyToRun precompiles some methods but still uses the .NET runtime and can use JIT. Native AOT produces a native executable that does not use JIT at runtime.

Q11. How do you publish a Native AOT application?

Enable <PublishAot>true</PublishAot> in the project file and run dotnet publish -c Release -r <RID> with the appropriate native toolchain installed.

Q12. What should you check before choosing Native AOT?

Check application dependencies, reflection usage, dynamic code generation, JSON serialization, database providers, deployment requirements and actual performance measurements.

🔙
ASP.NET Interview Questions-6 :👈 👉:ASP.NET-Interview-Questions-7