I got the error above in the following situation:
I developed a custom masterpage and on that masterpage I added a Label control. Afterwards, the label is filled up with some list data (in my case: information from a page library) . Maybe I could work with a webpart, but I don't think it's evident to put a webpart on a masterpage.
Everything worked fine until I saw that I coudn't add any webpart anymore. Believe me, it was hard to find out the cause of the problem. After excluding many possibilities I discovered that it was something in my masterpage. And guess what ... my innocent label was the cause of the whole thing!
Because of the fact that my code works fine in DisplayMode of a page, I surrounded my code with the following condition:
//Populate the "innocent" label
The condition will check whether you are in DisplayMode are not... If so... populate the label.