MDI & SDI Serialize with OCC

Hi Everybody, In a prototype I'm developping, I've tried to use MFC Serialization with an SDI project created with the standard MFC AppWizard. I've initialized all the AIS stuff, Viewer, View and WNTGraphicDevice as described in the SampleViewer3d documentation (an MDI application). When calling the (empty) Serialize method of the Doc object I get an unhandled exception in TKSERVICE.DLL (Stack Overflow). The same initialization code works fine with an MFC MDI skeleton. As all the Viewer samples I've inspected are MDI applications, I'm wondering if anybody has experienced the same problem and found a workaround. Thanks in advance for any answer.

Sylvain Moisan's picture


I have the same problem. I don't know if it's really possible to have an SDI App with OpenCascade.

The crash is due to CView::OnInitalUpdate which is called after each OnNewDocument msg. At this moment the prog. try to allocate new memory (ex: a new WntWindow) which overflow the stack.

I get rid of it but I wanted to try to have only one CView (instead of CView + CView3D that is illogical). With this new try, the DrawRectangle feature for selecting an object crash immediately when I click the first time to define the first corner of the rectangular selection (ex: to do an area zooming).

I don't know what to do, and I must say that MDI App. are not managed very well : try to have 2 child windows, then do an action on the first one : result is sometime done if you select the second and come back to reselect the first ! ...

S. Routelous's picture

Take care !!! This problem is perhaps only an OpenGL problem because of your graphic card.

Did you try your application on another computer , with another graphic card ? Do you have the latest drivers for your graphic card ?


liyubo's picture

Yep, in CView::OnInitalUpdate() I initialize a new WNTWindow and when I click New Document it has a stack overflow at


Could you tell me how do you solve it? is there anyone have the same promblem? please help!

liyubo's picture

I have the same problem and it make me crazy. Is there anyone know how to fix it?