COMException generated while trying to customize an Office document

I'm trying to add a customization module to a document (Excel for example) using ServerDocument.AddCustomization() as told in msdn help but an exception is raised:

"Unable to cast COM object of type 'VSTOPersist.Interop.VSTOPersistWordClass' to interface type 'Microsoft.VisualStudio.Tools.Applications.Runtime.IAppInfoDocument'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{09989249-3281-432A-8BF8-6C680EEAF1B5}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE))."

I need to mention that this error appears only when I'm trying to customize a document without Runtime Storage Control, otherwise customization works ok. I'm specifing the .application file to use so this is not a problem, otherwise it wouldn't load specified .dll even if customization would not fail.

Customization is working ok by adding the _assemblyname and _assemblylocation properties to a new document, but I need to cutomize it programatically.

Everywhere I've looked I didn't find this problem so any help would be much appreciated.





Answer this question

COMException generated while trying to customize an Office document

  • MAMMOTH_MK

    Yes, it's a development machine with Visual Studio 2005 and VSTO. Since I'm programming on it I'm using Office programs very often.

    And, as I said before, when I'm opening a new Excel document and add to it _assemblyname & _assemblylocation the next time it starts it is creating the activex to hold manifest and VSTO module is running ok. I guess if some things were not installed it had not to work in any case.

    Thank you for your quick reply!




  • Johan Stenberg

    I've found the problem.
    Somehow Visual Studio 2005 Tools For Office nor Office Service Pack 2 are installing properly VSTO Runtime interfaces used for customization. As soon as I reinstalled VSTO Runtime by using vstor.exe (I chose Repair option, so it was already installed) everything worked ok.
    Because I've been working for some time on the VSTO application and I didn't have any problems with COMs (this is the first COMException raised) I incline to believe Office SP2 is not installing corectly only the customization interfaces.


    Thank you for support.




  • Brian Brashear

    Does the computer that is running the AddCustomization code have Excel installed on it

    Thanks,

    Ade



  • COMException generated while trying to customize an Office document