Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Inventor 2012 getobject(, inventor.application)

8 REPLIES 8
Reply
Message 1 of 9
montylowe
2457 Views, 8 Replies

Inventor 2012 getobject(, inventor.application)

Having issues with the getobject(, "inventor.application") and the createobject( "inventor.application") with Inventoe 2012

 

giving me Error "can't create AxtiveX Object"

 

running from external windows form application  VB.net 2010

8 REPLIES 8
Message 2 of 9
YuhanZhang
in reply to: montylowe

Can you try to launch Inventor once then check the code again?

 

Also please post some code around the error if you still see the failure.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 3 of 9
montylowe
in reply to: YuhanZhang

It works fine on an XP loaded machine but will not work on Windows 7.

Message 4 of 9
squinton_axh
in reply to: YuhanZhang

‘ Try to get an active instance of Inventor

Try

          m_inventorApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application")

Catch ex As Exception

End Try

 

' If not active, create a new Inventor session

If m_inventorApp Is Nothing Then

          Dim inventorAppType As Type = System.Type.GetTypeFromProgID("Inventor.Application")

          m_inventorApp = System.Activator.CreateInstance(inventorAppType)

 

          m_quitInventor = True 

End If

 

Pretty strait forward code. The error that gets thrown is an "Invalid String Exception". I've been able to compile the code and run it on a Windows XP machine, however I am unable to get the code to work on a Windows 7 machine.

 

Incase you're wondering, I work with Monty.

Message 5 of 9
Mike.Wohletz
in reply to: squinton_axh

I have the exact same problem with only one Windows 7 machine, I have about 6 other Win 7 machines that it works on just fine. the only thing that I can figure is that the one I cant get it to work on is a home edition.

 

Message 6 of 9
YuhanZhang
in reply to: squinton_axh

May I have more info from you about your OS details(edition, x64 or x86?)? Are you the administrator of the OS, and have your the UAC(user access control) on? Is your Inventor/OS a localized build? And on which line you got the exception(GetActiveObject)? Seems that you have a different exception from Monty's.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 7 of 9
squinton_axh
in reply to: YuhanZhang

Windows 7 Professional x86

 

The UAC settings are still set at the default levels.

 

Both builds are localized.

 

The exception does occur on the "GetActiveObject" line.

r

The exception Monty was discribing is the same issue, just throwing a different exception because that was received using different code. We first started testing this on our own code, in which we use the "GetObject" command. When we couldn't get around the "Cannot create ActiveX control" error we were getting from "GetObject" I switched to the sample code that came in the SDK package for Inventor 2011. That is where the above code came from. I originally thought the problem might be from the fact that I had installed Inventor 2012 on my machine while still having 2011 installed. I have since done a complete uninstall of all Autodesk products following the steps outlined here. I will do another clean uninstall and reinstall and test the code with the UAC settings turned off.

Message 8 of 9
squinton_axh
in reply to: squinton_axh

Update:

Disabling the UAC for my computer now allows the "GetActiveObject" line to function as it's supposed to. Also the code now executes the "CreateInstance" line as it's supposed to. Thank you guys for your help.

 

 

Recap:

Disabling the UAC settings on my computer fixed this problem. You can access these settings through the Control Panel > User Accounts > Change User Account Control settings.

Message 9 of 9
juha.perala
in reply to: montylowe

Hi,

This is very old discussion, but I thought I would add my solution also in case someone else happens to google this same thread in hope of an answer.

 

I'm using Visual Studio and doing something similar. I had the same issue with the getobject not working with "inventor.application" parameter. The way I fixed this was by switching the .net environment to different version. I was using 5.0 and I got the error with that, but soon as I started a new project and used .net 4.0 the getobject worked just fine. 

I'm not sure if you'd be able to get it working by just adding some missing references, but in this way it at least works. 

-JuhaP

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report