2 Replies Latest reply: May 15, 2014 10:01 AM by Nick Osdale-Popa RSS

    Monarch COM Module

    DoMaNo _

      Trying to use the COM module in a .net application and am not being successful. 

       

      It seems that .Net will not access the COM object correctly simply by adding a reference to it inside the C# project.

       

      This is the error I got.

       

      Unable to cast COM object of type

      'MONARCHLib.MonarchClass' to interface type 'MONARCHLib._DMonarch'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{0D73C440-D7B9-101B-A6B5-00AA001B1AB4}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

       

      private void Form1_Load(object sender, EventArgs e)

              {

         MonarchClass monarch = null;

         bool isMonarchActive = false;

       

                  try

                  {

                      monarch = new MonarchClass();

                      isMonarchActive = monarch.IsActive();

                  }

                  catch (Exception ex)

                  {

                      string s = ex.Message;

                      if (ex.InnerException != null)

                      {

                          s += ex.InnerException.Message;

                      }

                      MessageBox.Show("Error Opening Morach

      Object: " + s);

                      txtOutput.Text = s;

                  }

                   

                  if (isMonarchActive)

                  {

                      // open script, append true/false

                      bool isOpenFile =

      monarch.SetReportFile(@"C:\classic.prn", false);

                      if (isOpenFile)

                      {

                          bool isOpenMod =

      monarch.SetModelFile(@"C:\Lesson12.mod");

       

                      }

                  }

      }

       

      Any thoughts?