Finally, I found Microsoft's official document "isolated applications and side-by-side assemblies", which was originally a technology available when XP was launched. I used to hear that I have never thought about it. It turns out to be so knowledgeable.
This article "how to build and service isolated applications and side-by-side assemblies for Windows XP" is detailed. After reading this article, I will understand the implementation principles and development steps. The article said that. NET Framework also uses the same technology (Simplifying deployment and solving DLL hell with the. NET Framework), but it is simpler. In the past, I thought that the concept of assembly was invented by. net, but it was just invented by it!
Summary:
Benefits of using assembly
1. Different versions of a component can be loaded in the same process by side (of course, the component must be able to handle such coexistence ).
2. You can use the COM component without the registry.
How to create an assembly?
Compile a manifest file. This is the simplest private assembly. If you want to share the file, you also need to sign the file and install it in the winsxs Directory, which is a little troublesome.
Why use private assembly?
Because it is put together with the application, side by side seems meaningless. However, you can prepare for converting to share assembly in the future. In addition, you can use COM components that do not require a registry.
How to Develop a side by side assembly?
It is not easy for developers to load different versions of a DLL/assembly in the same process. You need to consider many situations. For example, avoid data exchange between Assemblies of different versions, because the structures may be inconsistent. For example, avoid using shared memory and global semaphores.
Why does the winsxs directory become larger and larger?
Some people on the Internet say that their winsxs directory has already reached a dozen g, which is too exaggerated. Some people say that they only have a dozen MB. What is this?
This is because the Assembly will not be changed after it is released. If there is a bug modification, a new version will be released and will coexist with the old version. In this way, you can maintain compatibility and install updates without restarting your computer. In short, it is very convenient. However, with the increase of time, the system and applications will be constantly upgraded, the Assembly version will become more and more, and the occupied hard disk space will naturally become larger and larger.
How to update assembly?
Side by side achieves version compatibility by forcibly specifying the version number of the Assembly, but how to update the Assembly in that case? If Assembly changes the version number, the application dependent on it cannot automatically enjoy updates. If the version number is not changed, the incompatibility problem of the DLL hell version will arise.
Microsoft uses publisher configuration to solve this problem. You can force all (or specified) old versions to be automatically transferred to the new version. At this time, along with the release of the new version assembly, a publisher configuration is released to force the version number jump (redirect ). In this way, the new version of assembly can be used without re-packaging and deployment of published applications. Of course, the new version of assembly must be backward compatible. Publisher configuration is a global jump. You can also perform different jumps for different applications, that is, application configuration. Both configurations change the binding relationship between their assemblies without changing the existing applications, and are suitable for centralized policy-based management. Application configuration can override the publisher confiuration setting and enforce dependency on a specific assembly version to ensure compatibility-This makes it possible to miss important Assembly updates.
It is a dilemma to maintain the isolation between different assemblies and to automatically update them. There is no perfect solution at all. Publisher configuration and application configuration only provide a balanced solution.
Summary
In a complex and constantly evolving system, component version management is a big problem. How to gradually evolve without changing existing applications is a major challenge.