Grapher COM Connection to C#

2

I've been trying to automate Golden Software's Grapher (version 15) using C#. The program's guide for C++ (the file looks old, however, and I am not sure if it applies in a similar way now) notes that the user should:

  1. Create a new AppWizard dialog-based application, using all the standard options.
  2. Edit the main dialog resource to contain the desired UI. In this example, a Run and Close button.
  3. Use Class Wizard to add a handler for the "Run" button.
  4. Start Class Wizard, choose Add Class..., From a Type Library...
  5. Grapher's type library is contained within the grapher.tlb file, so select this file. Rename the classes, in order, Document, Worksheet, Application, Documents. Add all classes.

To me, this meant that I tried to use (after some other reading) the tlbimp command in developer prompt which I used to translate the "grapher.tlb" file into "GrapherTypeLib.dll". I further used regasm to register this file (as some places seemed to suggest this is necessary).

I added the reference to GrapherTypeLib.dll to my C# project along with making it not embed and to have a local copy.

However, with my code:

using System;
using System.Data;

using GrapherTypeLib;

public class Grapher15
    {
        public Grapher15(Functions _function, string _data, DataTable _summary, IProgress<int> progress)
        {
            try
            {
                CreateProfiles(_data);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        private void CreateProfiles(string _data)
        {
            // Create an instance which can work in the background
            IAppObject _instance = new ApplicationClass();
            _instance.Visible = true;
        }
    }

I always crash out trying to create the application. I should note that I have tried different options here, including new Application(), which result in the same thing:

System.Runtime.InteropServices.COMException: 'Retrieving the COM class factory for component with CLSID {41F3A3D2-EAF3-42F0-9F62-A6E55F08F7E7} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).'

Based on my above checks and regasm, I would have thought that everything is registered properly. I should note that when this first started, I also re-installed the program to make sure all of the registrations were done properly. However, I then decided to check regedit and that doesn't actually seem to have the one CLSID this is looking for:

enter image description here

I started investigating and using ildasm, I found out that this GUID matches what should be the registry value for GrapherTypeLib.ApplicationClass which does not seem to be registered in the regid listing. At the same time, ildasm notes, for example, a different value to GrapherTypeLib.Application than what is in the above regid list.

So, for a short conclusion -- does anyone have any idea what is going wrong in the above?

c#
com
asked on Stack Overflow Sep 30, 2019 by gktscrk

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0