There are a couple of possibilities for this exception. But if it is intermittent then there's really only one. Your code is leaking window handles. A program can allocate up to 10,000 of them before Windows pulls the plug and refuses to allow it to create any more.
Hard to repro because leaks like this take a while to build up to the quota. But easily observed from Taskmgr.exe. Click the Processes tab, View + Select columns and tick "USER objects". Observe this number while you run your program. It will go up by one every time your app creates a new form or control. And should go down when you close a form.
Unfortunately it is fairly easy to make a mistake that causes such a leak. It happens when you remove a control from a form without calling its Dispose() method. Or calling Controls.Clear() without disposing the controls first. Controls that are removed like that are temporarily hosted on the "parking window". With the intent that it will survive long enough to allow you to move them to another container. If that doesn't happen then the window handle for the control is permanently leaked.