Defer loading DLL?

  • Thread starter Thread starter Sri Prasad Tadimalla
  • Start date Start date
S

Sri Prasad Tadimalla

Is there a way to defer loading of a DLL until it is referenced by a method?
Our product ships optional DLLs and we want to avoid writing wrapper classes
to isolate calls to those DLLs. This is becoming cumbersome as we develop
more licensed components.

Perhaps there is a way to protect this code in some kind of tag?

Thanks,
Prasad
 
It has been my experience that a DLL won't be loaded until something in it
is referenced by a method. If you have conditional code in there that may
or may not make use of a certain object, the DLL for that object will be
loaded regardless, so you need to move that stuff out to its own method if
that's the case.
 
Additionally, there is no way to unload the assemblies once loaded ....
one way to get around this is to load the assembly in it's own appdomain
and dispose of that domain when you are done with it.
 
Back
Top