I have an experimental .net project which implements a custom DLL loader, implemented as an AssemblyResolve event handler. It works great except...
If the DLL being loaded is present in the same folder as the EXE, my custom event handler is bypassed.
Is there a way for my custom DLL loader to take precedence?
The chain of events might look like this:
- The EXE and core DLLs are loaded and run as normal.
- The code sets its custom handler as the primary DLL loader.
- Some other code needs to load a DLL. My custom code is called and a loaded Assembly object is returned.
- Some more code needs to load another DLL. My custom code is called but declines, returning a NULL Assembly object. The normal DLL loader then takes over.
Note: This question asks for a similar scenario but the answers explore a very different strategy that's not really applicable here.