eInvalidInput error calling SetSystemVariable during Initialize()

I have a component, which runs on startup of our AutoCAD OEM product, that has the following line of code in the Initialize method. This line of code is throwing an eInvalidInput exception.

 Application.SetSystemVariable("DYNMODE", 3);

I can put this line of code in a different method that I call after our application is loaded and I don’t get any errors, so it just seems to happen if it’s in the Initialize method.

I tested the same component with a standalone version of AutoCAD and the component loads on startup without any issue.

Has anyone run into this, or something similar?

This error seemed to go away after a full new build of all of our assemblies and creating a new build with the Make Wizzard

Yeah, using the Make Wizard each time is the way to go. We experienced far less issues after automating it to run each time we build an Installer and Update.