Formally, it sounds like a nonsense. There is no such concept as "call to a DLL". And, if you have a call to a DLL which is not loaded, this is not, by definition, a call.
However, something close to it may have real practical sense. For simplicity, let's assume that this is not just a DLL, but is a main module of some .NET assembly. If this is a native DLL, this is also possible, but as you did not mention what it is, let me do the assumption which makes the speculations easier. (We can later discuss native DLLs if on your request, if you are interested.)
So, you can have some "plug-in" interface which may or may not be implemented in some assembly, which is not yest loaded. But the interface is known by the implementing assembly and the host assembly (otherwise, how would you work with plug-ins?). Now, you can defer loading of the assembly before the call. To do that, add yet another implementation of the interface, in the host assembly.
Let's say:
public interface IPlugin {
void UpdateCalculations();
void SomeOtherMethod();
}
On the host application:
class PluginWrapper : IPlugin {
IPlugin PluginImplementation;
string pluginFile;
void IPlugin.UpdateCalculations() {
if (PluginImplementation == null)
PluginImplementation.LoadAndGetImplementation(pluginFile);
PluginImplementation.UpdateCalculations();
}
void IPlugin.SomeOtherMethod() {
if (PluginImplementation == null)
PluginImplementation.LoadAndGetImplementation(pluginFile);
PluginImplementation.SomeOtherMethod();
}
IPlugin LoadAndGetImplementation(string pluginFile) {
System.Reflection.Assembly assembly = System.Reflection.Assembly.LoadFrom(pluginFile);
}
}
Sorry for writing it in C# — I only want to conduct the idea, and you should understand at least some C#, is you use .NET.
Also, I did not give you much detail on reflection operations as I'm not sure you want to work with .NET assemblies. If you clarify on what you want to do and ask me further questions, I'll answer.
If you want to load native (unmanaged) DLLs, you can do something similar, but then host-side "PluginWrapper" would have somewhat different interface than native DLL (which won't really export classes). You just wrap all DLL calls the way convenient for you.
—SA