This exception is triggered when an operation that requires a session context is used outside of a session context. This happens when trying to create a WebPage from the App.Opening event, for example.
Manipulation of controls that are attached to a session need to know which session they come from. The framework hooks up each request that comes in to a particular session by the thread it is running on. Some reasons for this exception include:
You create a new control in response to an event that fires on the main thread (like a socket's DataAvailable event)
You have UI code running in a Thread that is not declared as a WebThread.
You attempt to create a control in response to HandleUrl or HandleSpecialUrl which have no knowledge of a session.
All project types on all supported operating systems.