Assembly Introduction

Microsoft Windows application program often dragged down by a dynamic link library, which is "DLL Hell" problem, in the face of such problems, the application program one of the components will be other application program incompatible components covered, the results so disturbed the application program completely unable to work properly. The problem is difficult to diagnose, because they only issue assemblies after installing some time to come out of nowhere. Visual Basic application program DLL hell problem is even more notorious as a Visual Basic application language development program compared to other programming application language development program with a greater degree of external dependencies. Microsoft's .NET initiative is expected to adopt a new distribution unit Assembly (Assembly) to alleviate this serious problem.

assembly of Mechanisms

From the program 's point of view, an assembly is functionally equivalent to a Java package: it provides libraries of related classes and can define their distribution range. For those who are not familiar with Java, in the development and application program when, assembly of the .NET tantamount to the DLL file in COM, but assembly of a plurality of document components.

Assembly may be called by the list ( the manifest self) documentation of this is that they are more superior compared to a typical DLL feature. The assembly contained in the list, the metadata describing the assembly of the derived classes, these classes required for external attachment, the use of permissions and assembly required versions of such control information composed of dependency. Within the .NET framework, assembly provides a common name for a single version of the file type and can not be versioned. So you do not have to check multiple files in order to determine the system installed on the component version, which is the most we ever feel angry place. This version of the control features of .NET DLL hell can almost completely eliminate the disease.

Private and public assembly assembly

In the case of default, .NET's assembly is private, which means they can only be one application program used. Private assembly should be attached to the application program where the folder or sub-folders. Microsoft is hoping most .NET developers can employ private assembly, and in fact it also encourages people to do so.

However, this will bring a potential problem: because the user may have multiple copies of the same private assembly's become cluttered hard disk, this is really very ironic, but rather sounds as if COM easier to solve this problem . Microsoft is more than this to respond to criticism: ". HDD is very cheap, buy more on the line" Fortunately, you can easily put the assembly into private public assembly, even without having to recompile or edit code.

Share beauty

The main difference between shared and private assembly assembly is that the former is usually stored in a special named Global Assembly Cache (referred to as the GAC). GAC sometimes in Microsoft document is called Global Assembly Store, it may be because the latter referred to some of them sound good.

GAC can store multiple versions of the same assembly, which is what Microsoft calls "shoulder to shoulder deployment" feature. This feature virtually eliminates the installation of the application program is not compatible with shared components affect other application program possibilities, this is definitely good news for developers.

Customers can specify the assembly or those which it is compatible versions of a shared assembly. If the client program version of the requirements can not be met, then it will not load any server assembly .NET runtime. Incidentally, .NET version of the assembly is represented by a four-digit format, such as forms: a major version number minor version numbers to create a version revision number....

defaulted. Assembly is considered a shared assembly can only be compatible with the same major and minor version numbers. However loader was loading priority compared to client version with a higher version number or create revision number of assembly operation, if there is such an assembly, it will automatically provide repair support. This default behavior is not always what you want, so the program or system administrator can define custom version control strategy, for example, forced to load a particular version or disable the loader to create a higher version number or assembly loading revision number.

In the Beta version 1, version control strategy contained in a number of XML documents, and these documents do not have to reside in the application program directory or to save in the Windows directory. These XML files define the relevant policies with specific software version and the version control system-wide strategy.

name

You can name the private assembly, as long as its name in the application program within a single can. On the other hand, we need to use some kind of public assembly globally unique identifier so that they can be identified .NET runtime. The COM Class ID and Prog ID already gone with the wind. Now sharing assembly adopted the so-called strong name naming scheme. Strong name comes from the standard public key encryption algorithm. Developers using a private key "signed" assembly while providing a public assembly for customers to use. Public key then becomes part of the strong name of the assembly.
 

Using task command-line compiler signed assembly need to use some command line options command, so this is a relatively onerous. Fortunately, Visual Studio.NET automatically for the program to complete these worker.

Little do great assembly

Microsoft finally acknowledged the existence of DLL hell problem, but also aware of the problem can only exert control strategy can be compensated by the operating system level. And in the registry of COM application program individual components of this support after Scrapped together, and looks as if Microsoft has embarked on the right path. In fact, with the assembly mechanism, install .NET application program may well become use Xcopy command to copy the program so simple!

Reproduced in: https: //www.cnblogs.com/softwareking/archive/2011/03/06/1972557.html

Guess you like

Origin blog.csdn.net/weixin_34290390/article/details/93766390