HSM-API from Standalone-EXE: Library not registered

HSM-API from Standalone-EXE: Library not registered

astuy
Contributor Contributor
495 Views
2 Replies
Message 1 of 3

HSM-API from Standalone-EXE: Library not registered

astuy
Contributor
Contributor

With the following snippet I'm trying to access HSM API:

#region only in Standalone-EXE
var invAppType = Type.GetTypeFromProgID("Inventor.Application");
var invApplication = (Application)Activator.CreateInstance(invAppType);
invApplication.Documents.Open("Path\\to\\HSM-Part.ipt");
#endregion
// the following works inside Inventor-Addin, but not in Standalone EXE
var hsmAddin = invApplication.ApplicationAddIns.ItemById["{749E667C-2560-416A-A5E7-68B96FF997B1}"];
var hsmApi = (InventorHSMAddinAPI)hsmAddin.Automation;

 

As the snippet says: the last two lines work as expected in an Inventor-Addin. But running this from a Standalone-EXE, I get an Exception:

Library not registered. (Exception of HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED))

 

Is there missing a dll? Or what's the problem?

0 Likes
496 Views
2 Replies
  • HSM
Replies (2)
Message 2 of 3

yan.gauthier
Advocate
Advocate

to access Inventor object from outside, use Marshal:

 

 

 public static void Main()
        {
            
            Application InvApp;

            try
            {
                InvApp = (Inventor.Application)Marshal.GetActiveObject("Inventor.Application");
            }
            catch
            {
                MessageBox.Show(new Form() { TopMost = true }, "Unable to get Inventor, Please launch the application.");
                return;
            }

            // Here the fun begins
            //Prepare variables
            
        }

 

0 Likes
Message 3 of 3

astuy
Contributor
Contributor

Did you try to get the HSM-API? On my end the exception is still there...

Furthermore, I necessarily need a new Inventor-Instance and your way only works with a running Inventor instance.

 

0 Likes