Design File Events
Paul alluded to an issue, but you may have missed his point.
When a DGN file is first opened, there is no valid DgnFileP nor an active model. Hence, all pointers are valid until the file is fully open.
You should defer all code that attempts to obtain a file or model pointer until the DGN file is completely open. You do that by setting a system event callback, and moving all code that wants a file or model pointer to that callback.
#include <mssystem.fdf>
Your callback should match the function prototype SystemFunc_NewDesignFile. You specify your callback function to system function SetNewDesignFileFunction (SystemFunc_NewDesignFile newFunc);. Call SetNewDesignFileFunction() from your MdlMain().