Bugs we noticed in ShapeAppAdvancedMFC Sample
1. When I File | Open an already created and saved doc from hard drive, it opens once but if I open it again after closing it once, it throws a Debug Assertion Failed error message.
2. If I open a document through File | Open, then close it and again try to open it from the History list that is there in the File menu, the document does not open.
Observation: Problems 2 and 3 can be solved by removing the event handler from the AppAddIns and DocAddIns. i.e., commenting the event handler for the messagebox and the code for the messagebox itself.
Specifically: If we comment the following line in the function "public void AppAddIn_Startup(object sender, EventArgs e)" from the file ‘AppAddIn.cs’:
this.CreatedDrawing += new CreatedDrawingEventHandler(ShapeApp_CreatedDrawing);
If we comment the line from function "public void DocAddIn_Startup(object sender, EventArgs e)" in the file ‘DocAddIn.cs’:
this.ShapeAdded += new ShapeAddedEventHandler(DocAddIn_ShapeAdded);
Without the event handler hookup, the documents open properly.
So it may be that the MFC connection points for events are not releasing properly and that the associated MFC document is not completely released when it is closed by user. When user tries to open the document the second time, it fails with Debug Assert (#1) or silently (#2).
Possible workarounds:
The issue seems to be that the COM adapter is not freeing its native resources on Add In Unload. The best way to verify the same is to make the application sleep after Unload on In Proc addins and before loading the addins in external proc. This does the Revoke on the COM adapter finally releasing the resources and thereafter the event hook up in the modified app seems to work.
1. Have the hook done in the unmanaged way as we do in the C# advanced MFC sample.
2. Increasing time span (sleep) between the unload and load in the external process (not a clean soultion).
Posted
Aug 30 2007, 02:24 PM
by
Gary