I suppose you made this in c++? Or C#
Anyways try making a function for the dll handling and make that function handle the error if there is no or invalid content in the dll or whatever.
Might fix the crash if you load when not ingame, also makes it possible to start before cs go even started