I'm working on a Forms based program. This program internally loads several (30 ish) WebBrowser objects and shows one at a time in a panel depending on the user's input. After some use (non deterministic), the program closes itself.
The only hint I have about why it's closing itself is reported by Visual Studio 2013, which tells me that the program finished with code -1073740791 (0xc0000409). No more hints about why or where this behaviour happens.
I've done some research and I've found this:
The clue to the problem is in the exception code: 0xc0000409
0xc0000409 means STATUS_STACK_BUFFER_OVERRUN.
In other words, something in your program is writing past the current stack frame, corrupting data on the stack. The program has detected this and rather than let it continue, has thrown an exception.
Other sources, like this one say:
Exception Code 0xc0000409 Error Codes are caused in one way or another by misconfigured system files in your windows operating system.
Which I suspect is pointing me in the wrong direction, because the problem I'm describing only happens in my program.
What can I do to fix this issue or at least to have a more precise diagnostic about this bug?
EDIT: I've been doing more research. The official documentation says the following about WebBrowser:
The WebBrowser control is resource-intensive. Be sure to call the Dispose() method when you are finished using the control to ensure that all resources are released in a timely fashion. You must call the Dispose() method on the same thread that attached the events, which should always be the message or user-interface (UI) thread.
I've also found this question. I found it relevant because what I'm trying to do is more or less a multi tab program, the problem is that I can't dispose the objects because I must be able to retrieve the WebBrowser in the same state as I left it when I change tabs.
User contributions licensed under CC BY-SA 3.0