Howto close a project in the gui programmatically

H

Heiner Eichmann

Hi!

I have written an extension to the project 2007 gui. I followed the steps
described in http://msdn.microsoft.com/en-us/library/aa663367.aspx.
Essentially I have a com interop class implementing the
Extensibility.IDTExtensibility2 interface from C:\Program Files\Common
Files\Microsoft Shared\MSEnv\PublicAssemblies\Extensibility.dll. OnConnection
adds a menu entry to the menu bar. Its Click method calls

applicationObject.FileCloseEx(MSProject.PjSaveType.pjDoNotSave, false, true);

applicationObject is of the type
Microsoft.Office.Interop.MSProject.Application from
C:\WINDOWS\assembly\GAC\Microsoft.Office.Interop.MSProject\12.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.MSProject.dll.
I got a reference to it through the previous OnConnection call.

If I click on my menu extension the currently opened project closes as
expected.
But if I afterwards restart the gui (closing it and starting it again), I
can not open the project: "This project cannot be opened in read-write mode
because a previous checkin for this project is not complete. Do you want to
open this project read only?"

The error message is wrong, as the project was properly checked in. I have
to clean the cache GUIs to resolve this. So obviously my FileCloseEx call
corrupts the GUIs cache!

Some more details / experiments: I also tried other parameters, like

applicationObject.FileCloseEx(MSProject.PjSaveType.pjSave, true, true);

or

applicationObject.FileClose(MSProject.PjSaveType.pjSave, true);

The result is always the same.

If I start the Project 2007 GUI from the Visual Studio debugger, an error
message pops up in Visual Studio, if I close the Gui (after closing the
project as described above):

LoaderLock was detected
Message: Attempting managed execution inside OS Loader lock. Do not attempt
to run managed code inside a DllMain or image initialization function since
doing so can cause the application to hang.

I am using Microsoft Office Project 2007 (12.0.6211.1000) SP1 MSO
(12.0.6211.1000) and Visual Studio 2005 Version 8.0.50727.762
(SP.050727-7600)

My question is: is there a way, to close a project without leaving the cache
corrupt?


Best regards,


Heiner
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top