Assembly loading problems are difficult to debug, since there are at least two levels when working with managed and source code.
- When the executable is launched, the native loader must find the file, load it into memory, along with all the dependent DLLs, in order to run it.
- The native loader scans the assembly manifest to determine this information, and then simply searches for all the DLL files and loads them into memory (in order).
- You can easily see this process using WINDBG and pointing to the EXE and running it from Windbg. The list of loadable modules is a native bootloader.
- If the dependency is an assembly of .NET managed code, then the native loader passes the download request directly to the managed loader known as "Fusion".
- You can easily configure the FusionLOG viewer to see what happens http://msdn.microsoft.com/en-us/library/vstudio/e74a18c4%28v=vs.100%29.aspx
- Download crashes at the managed level or within the managed level are easily detected either through WINDBG for Native or in Fusion Log View mode for managed code.
A few tips for loading a managed DLL: if the assembly contains a link to a DLL that is not included in this assembly, there is a strict "probe" order that follows to search for a dll. At least three attempts to find DLLs in different places, for example, in the assembly, in the root path of the program and in the GAC. If three attempts fail, the download stops at this point and the program does not start. When this happens, it is often seen as an environmental problem at the system level; however, this is actually a programming problem, because if the prerequisites are not completely known to the system administrator, they cannot guess about it. If you are a programmer who includes other dependent dlls, you should always consider whether to place them in an assembly to stop this problem. Otherwise, you, system administrators, and people using your program will have to wait until the root cause, which takes a lot of time, is determined.
You can say what I told the other department to use this DLL, and I have no idea what these other dependencies are! This is not an excuse, as there are great tools like ILDASM and even managed Walkers Dependency codes that will tell you everything you need. The best way to package these “other” DLLs is to simply include them in your assembly.
John peters
source share