A class that implement IExtensionApplication would always run the Initialize() method when the DLL is loaded:
public class MyPlugin : IExtensionApplication
{
// this method is called when the DLL is loaded
public void Initialize()
{
// you code here to check the MdiActiveDocument settings
// you may also handle DocumentCreated event, so that whenever
// a new drawing or a drawing file is opened, you can also check the
// drawing settings
}
// this method is called when AutoCAD quits
public void Terminate()
{
// in most cases you probably do not need to do anything here
}
// your other code of the class goes here...
}
Make sure you use try...catch to wrap the code in the Initialize(), if the code may result in runtime exception.