GetType on a Dynamically Loaded Assembly

The application on which I'm working has the opportunity to dynamically load and assembly. Later in the application, one of the types from the loaded assembly need be retrieved using GetType. More specifically, the GetType was performed using a fully qualified type name (including the name of the assembly). But the GetType failed. Naturally, this begged the question of why GetType didn't find the type in the dynamically loaded assembly.

Ultimately, it comes down to how GetType operations. If you provide a string of the form "A,C" (for assembly,class), then GetType operates as if it were performing Assembly.Load(A).GetType(C).

Notice the Load method that is in there. If A exists in the default probing path, then there is not problem. But A doesn't include a fully qualified path. And if the assembly was originally loaded from a location other then the executable's directory, GetType will fail.

There are a couple of solutions to the problem.

1 - Put the assembly in the GAC. Then Load will find the assembly and GetType will work

2 - Add a codebase element to the config file. This element can be used to control the probing path, but you cannot probe outside of the executable's directories and subdirectories. The codebase element (which has to be created for each DLL) allows you to specify the full path to the assembly.