Trigger code while/ before Grasshopper opens file (after file is picked)

I’m hanging out at the TT Hackathon and working on writing some code to solve this issue: C# Scripted Component should automatically bind to Host API DLLs · Issue #184 · mcneel/rhino.inside-revit · GitHub

I have managed to write code which swaps out the referenced dll files, but the earliest I can make it run is after the file is done being opened. So as GH opens the script, the user is shown the “Assembly Reference could not be resolved” error (even though the error gets fixed as soon as the script is done being opened).

Is there any event (like a GH_OnFileOpenStart) that I could subscribe to?
Or is there some other clever way to get grasshopper to run the dll swapping code sooner?
My last ditch solution would be to subscribe to the DocumentServer.DocumentAdded and DocumentServer.DocumentRemoved events to add and remove the RIR assemblies so they aren’t present during file opening.

Current status of code is attached
Autoupdate Revit Version.gh (22.8 KB)

Thanks

Some additional progress:

Autoupdate Revit Version.gh (18.6 KB)

I’m considering generalizing this a bit and turning it into a “real” (ie compiled/ .gha) component called something like… “DLL Buddy”. Would that be useful to anyone (besides me)?