This situation is often encountered during development. In A. dll, the type in B. DLL needs to be reflected. If you do not pay attention to it, a runtime error will occur. For cross-assembly reflection, remember the following two points:
(1) If typeof is used, the cross-assembly reflection will certainly run normally. It can be said that typeof supports strong types. For example, type suptype = typeof (enterpriseserverbase. dataaccess. idbaccesser );
If the current Assembly does not add a reference to enterpriseserverbase. dll, an error is reported during compilation.
(2) If type. GetType is used, the situation is more complicated because type. GetType is non-strong. The type. GetType parameter is a string. If the target type indicated by string is not in the current Assembly, type. GetType will return null at runtime. Solution: First load the Target Assembly and then use the Assembly. GetType method. For example, Assembly ASMB = assembly. loadfrom ("enterpriseserverbase. dll ");
Type suptype = ASMB. GetType ("enterpriseserverbase. dataaccess. idbaccesser ");
Note that when type. when GetType is used, even if you have added the parameter iseserverbase. DLL reference, type. getType ("enterpriseserverbase. dataaccess. idbaccesser ") also returns NULL because of type. getType only searches for the type in the current dataset!