Unable to cast COM object/No such interface supported exception - InfoPath Dev
in

InfoPath Dev

Unable to cast COM object/No such interface supported exception

Last post 08-22-2008 07:50 AM by rhlnvf. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 08-22-2008 02:40 AM

    • rhlnvf
    • Not Ranked
    • Joined on 08-21-2008
    • Posts 4

    Unable to cast COM object/No such interface supported exception

    I'm really hoping (and expecting, to be honest) that I've made some simple mistake here, so please accept my apologies if this seems a little dim...

    Trying to build a little c# app that retrieves a dataset from a database (not a problem so far), and for each row, creates an infopath form that can then be emailed to a user for completion.  To that purpose, I've added references to the two Interops I can find: Microsoft.Office.Interop.InfoPath.dll (runtime v1.1.4322) & Microsoft.Office.Interop.InfoPath.Xml.dll (also runtime v1.1.4322)

    I've designed the infopath template form, and saved the .XSN to disk with the intent that my c# app can use it to create a new XDocument for an InfoPathApplication object.

    The code I'm attempting to use is as below:

                Microsoft.Office.Interop.InfoPath.Application infoPathApp = new Microsoft.Office.Interop.InfoPath.Application();
    object ob_svr;
    XDocument x_svr;
    try
    {
    infoPathApp.XDocuments.NewFromSolution("C:\\obj\\TestWallchartDB.xsn");
    //ob_svr = infoPathApp.XDocuments.NewFromSolution("C:\\obj\\TestWallchartDB.xsn");
    //x_svr = (XDocument) infoPathApp.XDocuments.NewFromSolution("C:\\obj\\TestWallchartDB.xsn");
    }
    catch (Exception ex)
    {
    /*Unable to cast COM object of type 'Microsoft.Office.Interop.InfoPath.XDocumentsCollectionClass'
    *to interface type 'Microsoft.Office.Interop.InfoPath.XDocuments2'. This operation failed because the
    *QueryInterface call on the COM component for the interface with IID '{096CD647-0786-11D1-95FA-0080C78EE3BB}'
    *failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
    */
                     throw;
    }

    With any of the three calls to the NewFromSolution method, I get the same 'unable to cast' exception. I've seen a fair few examples in these and other forums of people using the method from within Wallchart, so is it simply that I can't use the method from an external application?

    Many thanks in advance for thoughts

  • 08-22-2008 07:50 AM In reply to

    • rhlnvf
    • Not Ranked
    • Joined on 08-21-2008
    • Posts 4

    Re: Unable to cast COM object/No such interface supported exception

    Feel a bit solipsistic replying to my own post, but...

    I've spent some time considering whether it's something to do with my install, and I'm becoming more and more certain of that now, so here's a bit more information.

    I have installed:

    * Visual Studio 2005
    * InfoPath 2003 SP2
    * Microsoft Office InfoPath 2003 Toolkit for Visual Studio 2005

    The most recent work I've done on this is to follow one of the MS examples, specifically http://msdn.microsoft.com/en-us/library/aa948065(VS.80).aspx and I've received the same cast exception on the Application.XDocuments.New method when attempting to open a valid XML file.

Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.