iLogic rules didn't run via Dotnet programming in Inventor 2025

iLogic rules didn't run via Dotnet programming in Inventor 2025

eyad_ahmed_hegazy_2012
Explorer Explorer
1,806 Views
10 Replies
Message 1 of 11

iLogic rules didn't run via Dotnet programming in Inventor 2025

eyad_ahmed_hegazy_2012
Explorer
Explorer

Hi Guys
Before Inventor  2025 we can use the following sample of  c# .net code to run the document iLogic rules 

in winform with dotnet 4.8

 

            ApplicationAddIn Addins = InventorApplication.ApplicationAddIns.ItemById["{3bdd8d79-2179-4b11-8a5a-257b1c0263ac}"];
            if (!Addins.Activated)
                Addins.Activate();
            dynamic _iLogicAutomation = Addins.Automation;
            var Rules = _iLogicAutomation.Rules(doc);

 

 

and when we go with Inventor 2025 we get these error :

Message = "Typelib export: Type library is not registered. (Exception from HRESULT: 0x80131165)"

 

StackTrace = " at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)\r\n at System.Dynamic.ComRuntimeHelpers.GetITypeInfoFromIDispatch(IDispatch dispatch, Boolean throwIfMissingExpectedTypeInfo)\r\n at System.Dyna...


we fail to run iLogic on inventor 2025 and it run correctly in version of 2024 or later

0 Likes
Accepted solutions (1)
1,807 Views
10 Replies
Replies (10)
Message 2 of 11

CattabianiI
Collaborator
Collaborator

Instead of use dynamic at line 4:

IiLogicAutomation _iLogicAutomation = (IiLogicAutomation)Addins.Automation;

 

0 Likes
Message 3 of 11

lsyKDKZS
Observer
Observer

I have the exact same problem as described here, but the suggested fix just gives me another error:

 

System.InvalidCastException: 'Unable to cast COM object of type 'System.__ComObject' to interface type 'Autodesk.iLogic.Interfaces.IiLogicAutomation'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{91DF0977-6AF7-305B-A571-67AF76D7A4C9}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).'

 

Has anyone else tried this fix also?

0 Likes
Message 4 of 11

MjDeck
Autodesk
Autodesk

@lsyKDKZS , is your code in an external EXE that connects to Inventor? Or is it in an add-in?


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 5 of 11

lsyKDKZS
Observer
Observer

@MjDeck The error happens when running an external EXE, for debugging purposes, that connects to Inventor through COM. It seems to work fine when running as a plugin in Autodesk Platform Services.

0 Likes
Message 6 of 11

MjDeck
Autodesk
Autodesk
Accepted solution

Here's source for a sample app that runs the rules in the active document.
Note that this project is targeted to .NET 8. In Inventor 2025, the desktop version of Inventor is running on .NET 8. Inventor 2024 ran on .NET Framework 4.8.


Mike Deck
Software Developer
Autodesk, Inc.

Message 7 of 11

lsyKDKZS
Observer
Observer

@MjDeck Thank you! Your example works and I can confirm that the issue is .NET 4.8 vs .NET 8.

 

0 Likes
Message 8 of 11

MjDeck
Autodesk
Autodesk

@lsyKDKZS , there is a way to make it work from .NET 4.8 by making calls to low-level late binding system functions. This requires extra code, but if you don't have a lot of calls to the iLogic API then it might be manageable. Here's a sample .NET Framework 4.8 project. You can use the same code in .NET 8.


Mike Deck
Software Developer
Autodesk, Inc.

Message 9 of 11

eyad_ahmed_hegazy_2012
Explorer
Explorer

External exe

0 Likes
Message 10 of 11

eyad_ahmed_hegazy_2012
Explorer
Explorer

Thanks

I will try

0 Likes
Message 11 of 11

ole.lyso
Contributor
Contributor

Edit: @MjDeck 's solution works perfectly for all issues related to this.

0 Likes