This topic describes the relationship between the application domain and the Assembly. You mustLoad an assembly to the application domain before running the application.. Running a common application causesLoad several assemblies into an application domain. By default, the common language runtime loads an assembly to an application domain that contains the code that references the assembly. In this way, the code and data of the Assembly are independent of the application that uses the assembly.
If an assembly is used by multiple fields in a process, the Code (rather than data) of the Assembly can be shared by all the domains that reference the assembly.This will reduce the amount of memory used during the runtime. This method of sharing assembly code is similar to Microsoft Win32 API LoadLibrary's method of sharing code pages between processes that reference the same DLL. When the code of an assembly can be shared by all the fields in the process, the Assembly can be considered to be non-domain-specific. The runtime host determines whether to load the assembly in a domain-specific manner when the runtime is loaded into the process. For more information, see the CorBindToRuntimeEx document. This document can be found in the. NET Framework SDK Common Language Runtime Library host interface specification.
There are three options for loading a domain-specific assembly:
Do not load any assembly in the form of a domain-specific(Except Mscorlib, which is always loaded in a non-domain-specific form ). This setting is called a single domain because it is usually used when the host only runs a single application in the process.
Load all the assembly in the form of a non-domain-specific. This setting is used in the following situations: the process has multiple application domains, all of which run the same code.
Load an assembly with a strong name in the form of a domain-specific. This setting is used when multiple applications are running in the same process.
When you decide whether to load an assembly in a non-domain-specific form, you must weigh between reducing memory usage and reducing performance. If the Assembly contains frequently accessed static data or static methods, the execution speed of the Assembly that is not specific to the domain will be slow. The reason for slow access to static data or static methods is that the application needs to be isolated. Each application domain accessing the Assembly must have a separate copy of static data or static methods to avoid cross-origin boundary reference of objects in static variables. Therefore, the Runtime Library contains additional logic to direct the caller to an appropriate copy of static data or static methods. This additional logic will reduce the call speed.
If a set of different permissions are granted to an assembly in each domain, the Assembly will not be shared among the domains. This situation may occur when the runtime host sets an application domain-level security policy. If the permission groups granted to the Assembly are different in each domain, the Assembly should not be loaded in a non-domain-specific form.
An assembly is a basic component of. NET Framework programming. The Assembly performs the following functions:
No matter how you try to avoid dealing with shared assembly, you still need to share the Assembly among multiple applications.There are two main differences between shared assembly and private assembly.:Location and ID. Private Assembly must be in the directory or subdirectory where the application is located, and shared Assembly must be installed in a specific Global Cache called Global Assembly Cache (GAC. In Windows, GAC is located in the Assembly directory under the Windows System directory (for example, C: \ WinNT \ Assembly ).
Although the friendly name of the shared assembly is the same as that of the private assemblyThe. NET Runtime library uses a strong name (strong name) (also called shared name: shared name) to identify the shared assembly.. A strong name consists of friendly names (such as MathLibrary), Region information (such as: English), version number (such as 1.2.0.0), public key, and digital signature. Here, a strict authentication level provided by a strong name is required, because:
● It is expected that the Assembly developed by the company has a unique name and will not be copied by other companies.
● It is expected that different implementations or region information can be shared with multiple different versions of the Assembly.
● Prevent the hacker's "Trojan Horse" assembly from replacing the legal assembly, and use valid access permissions to seriously damage the system.
To better illustrate these problems, the following example illustrates how to convert a MathLibrary assembly to a shared assembly.
1.4.1 private assembly
Private assembly is the simplest assembly type. Private assembly is generally attached to some software and can only be used in the software. A common scenario with private assembly is to provide applications in the form of executable files or multiple libraries. The Code contained in these libraries can only be used for this application.
The system can ensure that the private assembly is not used by other software, because the application can only load the assembly in the folder where the main execution file is located or its subfolders..
Users generally want to install commercial software in their own directories so that the software package does not overwrite, modify, or load the private assembly of another software package. Private Assembly can only be used for your own software packages, so that you have more control over the software you use. Therefore, no security measures are required, this is because there is no risk that other commercial software will overwrite the original private assembly with a new version of assembly (except when the software specifically performs malicious damage operations ). The name does not conflict. If a class in a private assembly happens to have the same name as a class in a private assembly of another person, no problem occurs because a given application can only use the name of a private assembly.
Because private assembly is completely self-contained, the installation process is very simple. You only need to put the corresponding file in the corresponding folder of the file system (registry entry is not required). This process is called"0 impact (xcopy) installation ".
1.4.2 shared assembly
Shared assembly is a public library that can be used by other applications. Because other software can access Shared assembly, some protection measures must be taken to prevent the following risks:
● Name Conflict. the type of the shared Assembly execution of another company has the same name as the type in its own shared assembly. This is a serious problem because the client code can theoretically access these sets at the same time.
● The Assembly is overwritten by different versions of the same assembly-the new version is incompatible with some existing client code.
The solution to these problems is to place the shared assembly in a specific subdirectory tree of the file system, called the Global Assembly high-speed cache (GAC ). Unlike private assembly, you cannot simply copy shared assembly to the corresponding folder. Instead, you need to install it in the cache.. NET tool to check the assembly, and set a small folder hierarchy in the Assembly Cache to ensure the integrity of the Assembly.
To avoid name conflicts,The shared assembly should specify a name according to the private key encryption method (the private assembly only needs to specify the same name as its main file name ). This name is called strong name and is unique. It must be referenced by the application that you want to reference the shared assembly.
Issues related to overwrite assembly can be solved by specifying version information in the assembly list, or by simultaneous installation.
Contains the code executed by the Common Language Runtime Library. If the portable executable (PE) file does not have an associated assembly list, the Microsoft intermediate language (MSIL) code in the file is not executed. Note that each assembly can have only one entry point (DllMain, WinMain, or Main ).
The Assembly forms a security boundary. An assembly is the unit in which requests and permissions are granted. For more information about the security boundaries applied to the Assembly, see Assembly security considerations.
The Assembly forms a type boundary. Each type of identifier includes the name of the Assembly where the type resides. The MyType loaded in one assembly range is different from the MyType loaded in other Assembly ranges.
The Assembly forms the reference range boundary. The Assembly list contains the Assembly metadata used for parsing types and meeting resource requests. It specifies the types and resources exposed outside the assembly. This list also lists the other sets it depends on.
The Assembly forms the version boundary. An assembly is the smallest versionable unit in the Common Language Runtime Library. All types and resources in the same assembly are versioned into one unit. The Assembly List describes the version dependencies specified by any dependency assembly. For more information about version control, see Assembly version control.
The Assembly forms a deployment unit. When an application starts, only the Assembly called by the application must exist. Other assemblies (such as localized resources and assemblies containing Utility Classes) can be retrieved as needed. This simplifies the application during the first download. For more information about how to deploy an assembly, see deploy an application.
An assembly is a unit that supports parallel execution. For more information about running multiple Assembly versions, see program set and parallel (side-by-side) execution.
The Assembly can be static or dynamic. A static assembly can include the. NET Framework type (interfaces and classes) and the Assembly resources (bitmap, JPEG files, and resource files ). Static assembly is stored in portable executable (PE) files on disks. You can also use the. NET Framework to create a dynamic assembly. The dynamic assembly runs directly from the memory and is not stored on the disk before execution. You can save the dynamic assembly on the disk after it is executed.
There are several ways to create an assembly. You can use development tools used to create. dll or. exe files, such as Visual Studio. NET. You can use the tools provided in the. NET Framework SDK to create an assembly with modules created in other development environments. You can also use the Common Language Runtime library API (such as Reflection. Emit) to create a dynamic assembly.
Application domain Overview
Previously, process boundaries were used to isolate applications running on the same computer.. Each application is loaded into a separate process, which isolates the application from other applications running on the same computer.
The reason for isolating these applications is that the memory address is related to the process. In the target process, the memory pointer from one process to another cannot be used in any meaningful way. In addition, you cannot directly call between two processes. You must replace it with a proxy, which provides a certain degree of indirect.
Managed code must pass a verification process before it can run (unless the Administrator has authorized to skip this verification ). This verification process verifies the following: will these codes attempt to access invalid memory addresses? Will I try to execute some other operations that will cause the process (the process where the code is running) to fail? The Code passed this verification test will be considered as type-safe. Because the Common Language Runtime Library can verify whether the code is type-safe, it can provide the same isolation level as the process boundary, and its performance overhead is much lower.
The application domain provides a safer and more useful processing unit. The Common Language Runtime Library can use this unit to provide isolation between applications.. You can run several application domains in a single process with the same isolation level (in a separate process, this does not cause additional overhead for inter-process calls or inter-process switching. The ability to run multiple applications within a process significantly enhances the scalability of the server.
Isolating applications is also important for application security. For example, you can run several Web application controls in a single browser process, and make these controls inaccessible to each other's data and resources.
Application domain isolation has the following advantages:
Errors in one application do not affect other applications. Because the type-safe code does not cause memory errors, you can use the application domain to ensure that the code running in one domain does not affect other applications in the process.
A single application can be stopped without stopping the entire process. The application domain allows you to uninstall code running in a single application.
Note:You Cannot uninstall a single assembly or type. Only the entire domain can be detached.
Code running in one application cannot directly access code or resources in other applications. To enforce this isolation, the common language runtime prohibits direct calls between objects in different application domains. To transfer objects between domains, you can copy these objects or access these objects through a proxy. If an object is copied, the object is called locally. That is, the caller and the referenced object are in the same application domain. If an object is accessed through a proxy, the object is called remotely. In this case, the caller and the referenced object are located in different application domains. The Remote Call structure used for Inter-Domain invocation is the same as that used for inter-process invocation or for inter-computer invocation. Therefore, the metadata of the referenced object must be available for both application domains so that the method can be correctly compiled and called using JIT. If the called domain cannot access the metadata of the called object, compilation may fail, causing an exception of the System. IO. FileNotFound type. For more information, see use. NET to remotely access objects in other application domains. It is up to this object to determine how the cross-origin access object works. For more information, see MarshalByRefObject class.
The scope of the Code behavior is determined by the application where it runs. In other words, the application domain provides configuration settings such as the application version policy, the location of any remote Assembly accessed by the application, and the location information of the Assembly loaded to the domain.
The permissions granted to the code can be controlled by the application domain where the code runs.
MetaData refers to MetaData, also known as data.
Data?
When a data is stored in a shared volume, we can directly see that it is a document, or image, or video, or database file, all of which are data itself. However, when storing the data, the file system still produces a lot of data that cannot be directly seen, such as file search tables, path information, and address information in the file system, the data is called the metadata of documents, images, videos, and so on in the shared volume.
The main content of software management for SAN network storage and sharing is metadata, which controls the transmission of metadata among multiple hosts.
We can see the metadata storage in many places, and the video file data of the movies that are DOWN on the Internet,Right-click to view the attributes of the video file, such as the storage path, bit rate, file size, and the metadata of the video file as well as the Director, actor, and production unit.
It is used to describe the content, quality, representation, spatial reference, management, and other features of a geographical dataset in geospatial information, it is one of the core criteria for implementing geospatial information sharing.