Introduction
The DLL trap is a strange problem.
I believe that many users have such experiences. If your experiences were originally designed to run today, after you installed a new experience, all of a sudden, the power supply cannot work. This is not a problem with your hardware or application process.
But the lack of design for business systems, this is usually because the new application version overwrites the shared program library (DLL) and often modifies some existing applications.
The required "bug". The missing one is called DLL hell.
(DLL ). The biggest challenge for developers and System Administrators (and users) is version update. They spend a lot of time logging on to Windows.
(Regedit), however, is trying to solve the problem.
In the world of Microsoft. NET, software components no longer need to be registered! Net
The Framework contains some features that can eliminate the issue of "DLL hell". The new features of the "side-by-side" development mode are described as follows.
DLL & DLL hell
Why dynamic link library (DLL)-dynamic link linking?
At the beginning, Microsoft designed the dynamic route for Windows to retrieve its two main links: one is dynamic route, and the other is resource sharing. The example of resource sharing is quite simple. For example, I have mentioned
Windows has three core Dynamic Links: the kernel is mainly used to manage the system and application's recording, itinerary, and travel history; the user provides the user interface and information.
In terms of operating systems; in terms of GDI, it is necessary to compile, display, and other functions of the system. However, any function provided by these dynamic links can be used in every Windows environment when necessary.
. Because dll has the feature of saving memory, it has become the mainstream of Windows programming since Windows 3.1.
|
• Dynamic Route results can be shared by resources There may be many models that can be shared by many large community vendors, if each set of components has their own shared modules, it may cause a waste of disk space and cause problems. The work of some models has become both initial and offline. The best way is to maintain a program token, and then allow other applications to access the shared modules through sharing. Shared Mode The first is to create a dynamic link between the modules, and then access the computer through the host security program, so long as one of these products is installed, other products of their own can share the same set of dynamic products.
Assume that a function x is used by three applications A, B, and C. If the function is used as the destination or original program, function x will be a part of the primary line that contains A, B, and C. If the same line is applied to programs A, B, and C, function x will also use a memory, which is a method of making frequent changes to the memory. If the function is in the DLL format, the function does not become a part of the dynamic line after the function is written, in the future, if the Applications A, B, and C are rejected at the same time, the system only adds a letter for sharing between program a, program B, and program C, such as example.
|
|
Figure: the shared architecture of the program and DLL
|
|
• Dynamic Route results saved the computing space
The data source sharing of Dynamic Route results saves the disk space, while the dynamic route entry method saves the memory space. Dynamic Route results using the dynamic route entry method, dynamic route entry allows the program to be linked When the data or data source is stored, the data or data source placed in the dynamic route table can be effectively used. Regardless of whether the disk space is saved or the memory space is saved, it is intended to use the Dynamic Link Provides shared function data and system resources to reduce the hardware requirements of the entire Windows environment. |
DLL problems-DLL hell |
|
What's the problem with the dynamic route?
In fact, the library Library (Program Library sharing, saving the memory) is the origin of its shortcomings. Originally, it was a good DLL. One day it will become a DLL. Hell, I'm afraid it was unexpected by the programmer of the initial DLL.
The reason why dll exists Hell is also caused by the fact that the dynamic terminal can share the function data and data sources with other programs. It can also be shared and shared 」. How can this problem be solved? To allow other programs to share the dynamic route results Data or data source, designers of Dynamic Route results must carefully and implicitly examine Functional consistency, backtracing compatibility, and other critical issues, otherwise, once the dynamic route used by the program does not provide the functions for the specified period, Then the user will fall into the region for this purpose. However, to fully test consistency or backtracing compatibility, it is actually difficult, even if you really want to do it, it will also make the software vendors who use the dynamic computing products pay the equivalent cost. But is it necessary to pay these costs? Think about it now Today's e-commerce industry environment has experienced a considerable change when it comes to the initial Micrographic design. The current hardware is too much cheaper than the previous one. The personal computer's memory is from 64 MB. The power supply with a memory of MB is everywhere, while the hard disk capacity is measured in GB. In such a hardware environment, Windows Programming Language still needs to be tested and shared so hard. Question? In addition, the dynamic route entry saves a lot of system resources for Windows systems, as a result, the micro-engine has re-optimized the design concept of the dynamic production environment, and has also improved its business system. Improvement. I hope there will be no more users falling into the depth of the region because of the joint venture.
· Collect statistics of Data DLL hell
Let us think about it. If 90% of a program or object class meets our needs, 10% of the program or object class does not meet our needs, what should we do? For the sub-program, it is only possible to modify the "original program.
Counterfeit Program a will use object X. When program a is installed on the system, it will install object X at the same time, if another program B uses Object X, then program B can directly copy it to the hard drive for normal operation. X already exists in the system, which sounds good because program a and program B can share object X. However, for program A, the operation was good after security, and the operation may become impossible on an unknown day. Line. This is the DLL hell of the Created directory. The following describes the two types of kernel partitions of DLL hell.
Dynamic Route 1. The dynamic route does not have a compatible rule for backtracking.
If program a uses Object X of version 1.0, and program B uses Object X of Version 2.0 Version X (usually because of the late development time of program B and the use of a new version). How can this problem be solved? As a result, when program B is installed to the system, object x Version 2.0 must also be installed in the system. At this time, version 1.0 X will be replaced by version 2.0. In most cases, object x Version 2.0 is compatible with Version 1.0, so program a can still run normally, but sometimes it appears that version 2.0 and Version 1.0 If the version is incompatible, program a cannot be properly renewed at this time. This DLL The cause of hell is the designer, because Dynamic Tracing does not have a good principle of backtracing compatibility. I want to figure out that a.exe requires X. dll. Provided functions, but in the new version of X. dl l, the function is actually canceled. At this time, DLL hell may also be generated. However, as I have discussed earlier, it is often difficult to guarantee a backtracking compatibility. However, the hard configuration of personal computers is no longer as common as before, therefore, the micro-producer also proposes the so-called Side-- Side's Dynamic Links allow programs to have their own dynamic links, to avoid the occurrence of such DLL hell.
When again 2. The dynamic route results in a good way to backtrack compatible tasks, but the dynamic route results show bugs.
Another kind of problem is that the provider of object X is indeed considering version compatibility. From the perspective of the root component, the new version is also compatible, but there is a problem when program a uses the new version of object X. After all, program A does not run with the new version of object X. Who knows what happens?
|
|
Client |
Server DLL (X. dll) |
Server Codes |
Program a uses X 1.0 |
(X 1.0) (original version) |
Public setvalue (byval Value Integer) If Value <0 then Value = 0 End If M_value = Value End Property |
Program B uses X 2.0 |
(X 2.0) (updated) |
Public setvalue (byval Value Integer) 'Fix the bug
If value <0 Then
Err. Raise number: = app_error, Description: = "negative value" End If M_value = Value End Property |
|
|
As shown in the above table, X 2.0 of developers carefully read through The binary compatibility mode of VB6.0 controls the dll version, and all the internal guid values are identical with the methods and numbers, because one of X 1. 0 is named Value parameter. When this parameter is set to numeric, this parameter changes to zero, but cannot cause any negative loss. This practice is completely simplified, X Version 2.0 never solved this problem. If the value parameter is set to a numeric value, the numeric value is generated.
When program B is split to X 2.0, this program B It can also work normally. However, if X 2.0 is installed in the system, program a will take off. Previously, the program set value adequacy to-1. There will be no problems, but there will be a temporary issue during the current period. At the same time, the developer of program A did not choose the desired machine in this design. In many real cases, it is very difficult to control the dll version in the binary compatibility mode, Even if the binary compatibility mode controls the dll version, it may also cause the DLL hell. |
|
|
How does. net solve the problem of DLL hell?
Self-describing assembly)
Assembly is the relationship between simplified deployment and version management. Assembly is the basic unit of deployment and version management. It includes a group of resources and types.
(Type), as well as the metadata included in the group, also include the version information of the other groups on which the group was built. With comprehensive organization information, different versions of the same organization can also be used.
On the same machine, the Security Department works with the common statement to provide the root component of the organization information, dependent
Assemblies). The process of security protection and security relief is as simple as that of legal case and legal case, in the past, the so-called "DLL" was generated because of mutual security protection.
The version of hell is out of control and does not exist.
Figure. Self-describing assembly can include multiple cases
Metadata (Definition) is the relation that assembly can describe. Metadata is the definition information generated by the analyzer during the production and production operations,
Compliance, methods, events, and even assistance and marketing information can be included in the content, and the consistency between the certificate and the bank is guaranteed, completely replaces and surpasses the unified distributed IDL (Interface
Definition Language) case and type difference (Type
Library). At the same time, the metadata required by the component server and the primary row are all automatically generated from metadata .. Asseembly directive for identification
Assembly itself,. Assembly extern directives defines the other parts of the Assembly
Assemblies.
Figure. You can use il disassembler (ildasm) to present the DLL metadata.
Integrated deployment and Version Management |
|
• Application-Private Assemblies (isolated Assembly)
Application-private assemblies (or separated assembly) can only be used by one application- It cannot be shared by other applications. Install assembly to allow the program developer to have control rights over the application program. This is also true. The setting method of the. NET application program. The developed application-private assemblies must be in another. net During environment security, there is only one manual, that is, copy and Paste. As long as the program is compiled successfully, it is the EXE program, DLL component, ASP. NET. aspx website, or web Service. all asmx instances are deployed in the same category as the application in zookeeper/Observer mode. After these scenarios are completed, you do not need to specify external parameters or settings .. When the program is running, If external components are required, they are first located from the same object in the original line. Therefore, each application programming set uses components in the same category. Different applications cannot interact with each other. Except for DLL hell. (Outputs: the CLR finds these assemblies through a process Called probing. probing is simply a mapping of the Assembly name to Name of the file that contains the manifest .)
• Shared assemblies-side by side execution (And row)
However, it is necessary for applications to share the Assembly, because each application has its own copy (such System. windowns. Forms, system. Web or a common web forms Control ) Is a strange thing. To understand the problem about DLL hell,. Net has added a new technology called side. By side execution, which means that applications can have their own versions of DLL, such A uses objects of version 1.0, while program B uses objects of Version 2.0. Objects of version 1.0 and Version 2.0 can be stored in the system at the same time. Through side by side Execution technology, as long as the application is successfully installed, you do not need to worry about dll version updates or specification changes, because even if the DLL is changed, the program does not need to be replaced. The following statement Side by side execution processes and application steps: Figure . Process for implementing strong names
step 1. create a key pair using the Strong Name tool (Sn.exe) .
Sn-K mykey. SNK Strong names is a function that reduces the. net dll trap in the. NET architecture.
(Outputs: the author of an Assembly generates a key pair, signs File containing the manifest with the private key, and makes Public Key available to callers by the strong name tool. The key Pair is passed to the compiler using the custom assembly Attribute)
Step 2. sign an assembly with a strong name and version number:
In Assemblyinfo.vb, <assembly:AssemblyKeyFileAttribute("MyKey.snk")> <assembly:AssemblyVersion("1.0.0.1")
Step 3. Install Assembly to Global assembly cache (GAC) gacutil /i:myassembly.dll
(Usage: see the. NET Framework SDK documentation for a full Description of the options supported by gacutil .)
Figure : Global Assembly Cache
Step 4. Version Policy)
. NET provides a set of parameter settings to control the Assembly termination, Therefore, you can merge the related information in the program. Upgrade version of assembly. The organizational unit setting mechanism is set by XML to allow users to access the security, version, and terminal functions of the program. Each application can have an XML program preset to specify different versions of the assembly to be completed by the application.
The Script Name of the program is named "Add. config", for example, "myapp.exe. config.
The <bindingredirect> label indicates that. Net logs are imported into the new assembly version.
For example, if the following example is set, the marinectrl version 5.0.0.1 will be added instead of 5.0.0.0.
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly <assemblyIdentity name="MarineCtrl" publicKeyToken="9335a2124541cfb9" /> <bindingRedirect oldVersion="5.0.0.0" newVersion="5.0.0.1" /> </dependentAssembly> </assemblyBinding>
|
Summary
The. NET Framework net assembly
The self-description and version management functions make the deployment of zero-impact possible and link the DLL hell at the same time.
Application-private assemblies (or
Separated assemblies can only be used by one application-it will not be affected by other applications. The Assembly of the delimiter
Allow developers to control their applications and develop application-Private
Assemblies can be deployed in the same region as the application.
Through side by side
Execution technology. Once the program is successfully installed, you do not need to worry about dll version updates or specification changes. It allows an assembly
Multiple versions are installed and running on the same machine, and each application can be connected to different assembly versions.
The. NET Framework
Upgrade your application version information and use this information to access the assemblies of the correct version required by the application when you apply the application.