Internal Manifest vs External Manifest

Internal manifest is the RT_MANIFEST resource in the executable.  External manifest is App.exe.manifest. In Windows XP, Sxs searches external manifest before internal manifest. If an external manifest is found, the internal manifest is ignored.  In Windows Server 2003 and later, the order is reversed.  Internal manifest is preferred over external manifest. If you use external…


App Config’s root element should be namespace-less

The root element for Application config file is <configuration> <?xml version="1.0" encoding="utf-8" ?> <configuration > </configuration> The application config file is shared with CLR and Windows SxS. SxS dictates that the root element is <configuration>, and it should be without namespace. If the application config file does not follow the rule, SxS will refuse to…


Assembly Loading and Authorization

CLR does not do anything special regarding authorization during assembly loading. It will try to access the file under the current user. However, if an assembly is already loaded, next time when the assembly is requested, CLR will return the assembly from the cache without hitting the file. When the application impersonates a user, things…


Windows Vista Sxs Activation Context Cache

Sxs activation model is built on top of Actication Context. To create an activation context, use the API CreateActCtx. Activation Context is used very frequently in Windows. For example, a simple operation like start notepad, open the common file dialog, select a file, will call CreateActCtx many times (I measured 18 times in Vista). With…


The Unusual Ref/Def Mismatch FileLoadException

One of my colleagues has experienced a very strange Ref/Def Mismatch FileLoadException (The located assembly’s manifest definition does not match the assembly reference). After a long investigation, we finally track down the cause. To explain the problem, we have to understand the sequence of assembly loading and the interaction between fusion and CLR. The  key…


The sequence of interactions between CLR loader and fusion during Assembly.Load

The following describes roughly the sequence of interactions between CLR loader and fusion during Assembly.Load() in .Net framework 2.0. 1. User calls Assembly.Load. 2. Loader pass the assembly reference to fusion. 3. Fusion checks to see if the assembly has already loaded. If it is, the assembly is returned. 4. If not, fusion probes the…


64 bit gacutil.exe

32 bit gacutil.exe can install/uninstall/enumerate 64 bit assemblies for GAC, so there is really no need for 64 bit gacutil.exe.


BadImageFormatException maybe thrown when loading a valid assembly

We saw some cases when loading a perfect valid assembly, CLR may throw BadImageFormatException occasionally. In one particular case, we discover that it is caused by anti-virus scanners. Turn off the “Protection Against Unknown Threats” feature in the anti-virus engine and the problem disappears.



RT_MANIFEST Since Windows XP, Windows reserves a new type of resource RT_MANIFEST for SxS manifests. Within the RT_MANIFEST resource, Windows reserves ID 1-16. A binary cannot have two IDs of resource type RT_MANIFEST within 1-16. Windows will refuse to load such binary in Windows XP/Windows Server 2003. Only three IDs are used today in Windows….


Diagnose SideBySide failures in Windows XP/Windows Server 2003

Since I published my article on how to diagnose SideBySide failures, I have received many feedbacks that since Sxstrace is not available in Windows XP/Windows Server 2003, it is hard to figure out what is wrong in Windows XP/Windows Server 2003.   This article intends to help people diagnose SideBySide failures in Windows XP/Windows Server 2003. SideBySide failures…