When you load an assembly, one should use the assembly.FullName instead of assembly.Name, in order to avoid conflicts, which has the following format:
“SampleAssembly, Version=1.0.2004.0, Culture=neutral, PublicKeyToken=8744b20f8da049e3”
From MSDN documentation this string can also include “ProcessorArchitecture=????” where ???? can be MSIL, X86, etc. but is optional.
When ProcessorArchitecture property is not defined in the assemblyName string, what rule does Assembly.Load use to query the GAC in order to load an assembly that is compiled for multiple Processor Architectures (x86, Amd64, MSIL)?
Thank you in advance for your help.
It is implicit. By the time your Assembly.Load() statement runs, the loader shim has already decided whether the process runs in 32-bit or 64-bit mode. So when it, say, decided for 64-bit mode then only an assembly that targets msil or amd64 can work.
The GAC is divided in 3 parts, the sub-directory names are GAC_MSIL, GAC_32 and GAC_64. The fusion loader is going to look first in GAC_MSIL to see if a matching assembly can be found. Then looks in one of the two other ones for a match. There is no ambiguity.