Key Points of. Net assembly

Source: Internet
Author: User

1. An assembly consists of Assembly metadata, type metadata, intermediate language code, and resources. An important part of Assembly metadata is the assembly list,
It describes all the information required to reference this Assembly and lists all dependencies. A list consists of the following parts:
(1). identifier (name, version, culture, and public key ). The public key uniquely identifies an assembly.
(2). A list of files belonging to the Assembly. An assembly can have one or more files.
(3) List of assemblies referenced by the Assembly. The Assembly list shows all the assemblies used in the assembly, their version numbers and public keys.
(4). A set of license requests-the license required to run the assembly.
(5) export types defined in the module referenced by the Assembly.

2. There can be different namespaces in a dataset, and a namespace can also be distributed in multiple datasets.

3. An assembly is divided into a private assembly and a shared assembly. When a private assembly is referenced, if the Assembly is an EXE file, it cannot be referenced by adding a reference,
Copy it to the target directory manually. If it is a. dll file, you can add a reference. After the reference, the system automatically creates a copy of the Assembly in the target directory,
Manual copy is not required. For shared collections, the tool will be installed in the collections to be saved slowly. The gacutil.exe tool can be called in the script of the installation program.
In addition, if you want to view the Global Assembly Cache, open the c: \ windows \ Assembly folder.
Gacutil/L displays all the assemblies in the global assembly cache.
Gacutil/I mydll installs the shared Assembly mydll into the Global Assembly Cache.
Gacutil/u mydll uninstall the mydll assembly.
The method for referencing a shared assembly is the same as that for referencing a private DLL assembly, but the system will not copy the DLL copy to your target directory,
Instead, it loads the Assembly from the Assembly cache.

4. Strong Assembly name
The most important thing about a shared assembly is to have a globally unique name, which is called a strong name in. net. A strong name consists of the following parts:
(1). Assembly name
(2). version number. With the version number, you can use different versions of the same assembly at the same time. Different versions can exist at the same time and can be loaded to the same process at the same time.
(3). Public Key, which can ensure the uniqueness of Strong names. It can also ensure that the referenced assembly will not be tampered with or replaced.
(4). culture.

Create a strong name file:
Use Sn-K mykey. SNK on the command line to generate a public/private key pair and store it in the SNK file.
The private key is used to digitally sign a component. The public key is used by programs that reference the Assembly to verify the assembly. At the same time, the public key has become a part of the strong Assembly name.
For an assembly with a strong name, you can view this public key in the assembly list by using the ildasm decompilation tool.

5. About server components (Enterprise Services)
(1). The service component must have a strong name.
(2) Service components should be registered in the Global Assembly Cache (GAC) because these components are system-level resources. The server application must be installed in GAC,
This is not required for Library applications (but it is recommended to install it in GAC ).
(3) You can automatically register a service component with COM + by means of delayed registration, or you can manually register a service component with regsvcs.exe.
Automatic Registration (deployment ):
If the. NET client application that uses service components is started, the COM + application is automatically configured. This applies to all classes derived from servicedcomponent.
An important disadvantage of automatic deployment is that the customer's application requires administrative permissions during Automatic deployment. If your application is an ASP. NET application,
ASP. NET runtime libraries generally have no management permissions. Therefore, automatic deployment is only used in the development phase. Therefore, this makes it very convenient for developers to create
You do not need to manually deploy the service components.
Manual registration (deployment ):
Run the following command: regsvcs simpleserver. DLL to register the Assembly simpleserver as a COM + application.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.