Câu hỏi phỏng vấn .NET Core
Câu hỏi

What is a .NET application domain?

Câu trả lời

A .NET application domain, often referred to as an AppDomain, is a logical isolation boundary created around .NET applications to ensure that they do not access or affect each other. This concept is specific to the .NET Framework and provides several key benefits, including isolation, security, and the ability to unload assemblies without stopping the entire process.

Key Points about .NET Application Domains:

  1. Isolation: Application domains provide a unit of isolation for the Common Language Runtime (CLR). They are created and run inside a process, allowing multiple applications to run within the same process without interfering with each other[2][3].

  2. Security: AppDomains can be used to run code with different security levels. For example, you can run untrusted code in a separate AppDomain with restricted permissions, ensuring that it cannot access sensitive resources[1][3].

  3. Unloading Assemblies: One of the significant advantages of using AppDomains is the ability to unload assemblies. If an assembly is loaded into a secondary AppDomain, it can be unloaded by unloading the AppDomain, which helps in managing memory and resources more efficiently[3][9].

  4. Versioning and Reliability: AppDomains help in managing different versions of assemblies and improve the reliability of applications by isolating faults. If an AppDomain becomes unstable, it can be unloaded without affecting the entire process[1][3].

Example Usage:

In the .NET Framework, you can create and manage AppDomains programmatically using the AppDomain class. Here is a simple example of creating and unloading an AppDomain:

using System;

class Program
{
    static void Main()
    {
        // Create a new application domain
        AppDomain newDomain = AppDomain.CreateDomain("NewAppDomain");

        // Execute code in the new application domain
        newDomain.DoCallBack(() => Console.WriteLine("Hello from the new AppDomain!"));

        // Unload the application domain
        AppDomain.Unload(newDomain);
    }
}

Differences in .NET Core:

In .NET Core, the concept of AppDomains is limited. .NET Core does not support creating new AppDomains for isolation, unloading, or security bounda...

junior

junior

Gợi ý câu hỏi phỏng vấn

junior

What is MSIL?

expert

Could you name the difference between .Net Core, Portable, Standard, Compact, UWP, and PCL?

middle

What is the difference between Class Library (.NET Standard) and Class Library (.NET Core)?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào