"It is illegal to call out while inside message filter."

One of our ISVs ran into an issue that others writing managed code interoping with COM (nothing to do with SSIS directly) might run into. At some unpredictable time, he got an error message with the title of this blog entry while working in the designer. I couldn't find good information on the net on this topic, and have plagiarized something Michael, our tech lead, had written up. Any errors in the information below are solely mine:

The cause of the problem is that since the pipeline is free threaded, and most of the UI executes on the main VS thread, the call is marshaled to the free-threaded apartment using COM. While the main thread is waiting for such a call to complete, it can receive and handle other messages. That might result in reentrancy.

To avoid this, VS implements a message filter – a message filter that keeps most messages in a queue and prevent them from handling until the COM call is completed. 

However, certain events (like WM_PAINT… see https://support.microsoft.com/default.aspx?scid=kb;en-us;176399) are allowed to go through to allow repaints. A restriction of this code is that it should not make another COM call to a free threaded COM component.

The simplest way to avoid this is to avoid code that calls free-threaded objects in the drawing code. Ideally, the UI should cache any data it needs for drawing and use it. Another method is to avoid the COM marshalling and invoke the COM method from a non-UI (usually thread pool) thread, doing the marshalling yourself.

If you see this consistently (we've made quite a bit of an effort to avoid this), do drop me a line.

regards