Results 1 to 2 of 2

Thread: Error: Unable to cast COM object of type 'System.__ComObject' to interface type..

  1. #1
    Member
    Join Date
    2008-09
    Posts
    7
    Login to Give a bone
    0

    Question Error: Unable to cast COM object of type 'System.__ComObject' to interface type..

    I am working on integrating a NAvis Viewer in my Web Application. I am using the Navis API for listing the clashes in a Dropdown.
    But I get the error:
    [ERROR MESSAGE]
    Unable to cast COM object of type 'System.__ComObject' to interface type 'NavisWorksAPI6.InwPluginsColl'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{D74F889B-01BA-11D5-A066-00B0D011BBC8}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

    Code:
    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using NavisWorksAPI6;
    using NavisWorks6;
    
    public partial class Clash : System.Web.UI.Page
    {
        nwOpState m_state;
        InwOpClashElement m_clash = null;
        DocumentClass m_doc;
        public const string NWD_FILENAME = "C:\\Program Files\\Autodesk\\Navisworks Manage 2009\\API\\COM\\examples\\clashtest.nwd";
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
            m_doc = new DocumentClass();
            m_doc.Visible = true;
            m_state =(nwOpState)m_doc.State();
    
            m_doc.OpenFile(NWD_FILENAME);
            m_state.CurrentView.ViewPoint.Paradigm = nwEParadigm.eParadigm_APPLICATION;
    
            foreach (InwPluginsColl plugin in (InwPluginsColl)m_state.Plugins())  // ERROR LINE
            {
                InwPlugin plugin1;
                plugin1 = (InwPlugin)plugin;
                if (plugin1.ObjectName == "nwOpClashElement")
                {
                    m_clash = (InwOpClashElement)plugin;
                    break;
                }
            }
    
            if (m_clash == null)
            {
                Response.Write("Failed to find clash detective");
            }
    
            m_clash.RunAllTests("gatehouse.nwd");
    
            foreach (InwOclClashTest clashTest in m_clash.Tests())
            {
                ListBox1.Items.Add("# CLASH TEST - " + clashTest.name + "#");
                ListBox1.Items.Add("New Result:" + clashTest.NumNewResults);
                foreach (InwOclTestResult clashResult in clashTest.results())
                {
                    ListBox1.Items.Add("- RESULT[" + clashResult.name + "] Status[" + clashResult.status + "]");
                }
    
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
         
        }
    }

  2. #2
    Member
    Join Date
    2008-03
    Posts
    5
    Login to Give a bone
    0

    Default Re: Error: Unable to cast COM object of type 'System.__ComObject' to interface type..

    I had the same problem so i guess it is a bug of Navis. I got over it using late binding, when there's no need to cast.

Similar Threads

  1. 2016: Pipe Type/System Type Lock
    By Brodnax in forum Revit MEP - General
    Replies: 1
    Last Post: 2015-09-08, 06:35 PM
  2. 2015: Last type in System Family "xx" cannot be deleted error
    By HermanS in forum Revit MEP - Families
    Replies: 1
    Last Post: 2015-05-04, 08:31 AM
  3. Replies: 4
    Last Post: 2014-11-14, 04:01 AM
  4. Link Pipe Type and Duct type to system types.
    By Wish List System in forum Revit MEP - Wish List
    Replies: 0
    Last Post: 2014-03-21, 08:34 PM
  5. Replies: 13
    Last Post: 2006-10-13, 08:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •