Rhino loads plug-ins, which are regular MFC DLLs, using the LoadLibraryEx() Win32 SDK function. All plug-in types are loaded in the same manner.
Rhino plug-ins are loaded twice. The first time as follows:
hModule = ::LoadLibraryEx(
lpFileName,
0,
DONT_RESOLVE_DLL_REFERENCES | LOAD_WITH_ALTERED_SEARCH_PATH
);
Note that the plug-in is loaded without dependencies. This allows Rhino to quickly verify the Rhino SDK version and that the proper plug-in exports are available. Also, the altered search path flag is used so LoadLibraryEx() looks for dependent DLLs in the directory specified by lpFileName, not by Rhino4.exe.
The plug-in module is freed as follows:
::FreeLibrary( hModule );
If the above was successful, the plug-in is loaded for a final time as follows:
hModule = ::LoadLibraryEx(
lpFileName,
0,
LOAD_WITH_ALTERED_SEARCH_PATH
);
Again, the altered search path flag is used.
Rhino loads .NET plug-ins, which are regular .NET assemblies, using the Reflection classes in .NET
Rhino plug-ins are loaded twice. The first time using ReflectionOnlyLoadFrom to determine the version of Rhino_DotNet the plug-in was compiled against. If the version is more recent than what is installed on the user's computer, Rhino will notify the user that a more recent build of Rhino is required to run the plug-in.
The second time Rhino uses Reflection::Assembly::LoadFrom to load the plug-in. Once the plug-in is loaded, Rhino iterates through all of the public classes and creates instances of every command and plugin subclass.