Inventor API 2025 Getactive object is not getting!

Inventor API 2025 Getactive object is not getting!

pranav_sRUHFs
Explorer Explorer
821 Views
3 Replies
Message 1 of 4

Inventor API 2025 Getactive object is not getting!

pranav_sRUHFs
Explorer
Explorer

System.Runtime.InteropServices.Marshal.GetActiveObject cannot be found usually!   am getting this exception while running my code on inventor 2025 version.  below is my code sample. am getting document

Dim _invApp As Inventor.Application

Public Sub New()

' This call is required by the designer.
InitializeComponent()

Try
_invApp = Marshal.GetActiveObject("Inventor.Application")
Catch ex As Exception
Try
Dim invAppType As Type =
GetTypeFromProgID("Inventor.Application")

_invApp = CreateInstance(invAppType)
_invApp.Visible = True
Catch ex2 As Exception
MsgBox(ex2.ToString())
MsgBox("Unable to get or start Inventor")
End Try
End Try
' Add any initialization after the InitializeComponent() call.

End Sub.

exception.png

same code is running for 2024 inventor version.

  1. reference dll is added exact dll for inventor 2025 version
  2. i tried to build the same code in .net 8 i can't add winforms.
  3. i tried to upgrade the code as per inventor user manual Port .Net Framework-based project to .Net    https://help.autodesk.com/view/INVNTOR/2025/ENU/?guid=GUID-522FF5BC-7CC5-43D5-99B1-14840CF54A82 

This porting also does not loaded my dll 

4.no mistakes in my addin manifest also. cause its loads for 2025 also as a button 

can someone help?

0 Likes
822 Views
3 Replies
Replies (3)
Message 2 of 4

WCrihfield
Mentor
Mentor

Hi @pranav_sRUHFs.

System.Runtime.InteropServices.Marshal.GetActiveObject method is defined for .NET Framework only.

Microsoft.Visualbasic.Interaction.GetObject method is both .NET Framework and regular .NET.

I have been using the second one (GetObject) in my iLogic rules for several years now, but I am still using 2024.3 right now.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 4

Michael.Navara
Advisor
Advisor
0 Likes
Message 4 of 4

JelteDeJong
Mentor
Mentor

In my blog post "Migration addins to .Net core 8 (Inventor 2025)" I have a solution for this problem. See the part "Create Class Marshal2" (Almost at the bottom of the post.)

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com