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: 

Debugging 2012 addin with VS2010

18 REPLIES 18
Reply
Message 1 of 19
sellis
2757 Views, 18 Replies

Debugging 2012 addin with VS2010

I cannot debug an addin for Inventor 2012 from Visual Studio 2010 professional on Win7 64.

 

I started with a new “Autodesk Inventor Addin” project

Set debug “Start external program” to inventor

Added a form and called it from StandardAddInServer.Activate sub

 

IF I debug from here inventor starts but form does not open. Addin not loaded.

 

Move *.addin file to Inventor addins

 

Now when running debug, form opens but breakpoints do not work. VS reports no errors on build.

 

So... Is there a tutorial or good instructions for this anywhere? I could not find anything specific to 2012 addins.

 

I can go back to registering the com...

 

Thanks

Stan

18 REPLIES 18
Message 2 of 19
YuhanZhang
in reply to: sellis

Hi Stan,

 

Would you try with below steps:

 

  1. Install Inventor wizard from SDK\Developer Tools\Tools\Wizards\InventorWizards.msi.
  2. Open Visual Studio, new an Inventor addin project with template.
  3. Add you code to addin.
  4. Copy the .addin file to proper location according to step #3) in Readme.txt.
  5. In VS, open the addin Properties(Project->[addinname] Properties), on Compile tab, set below settings:

    Configuration: Debug

    Build output path: C:\Program Files\Autodesk\Inventor [version]\Bin

    (this will avoid manually copying the binary to that folder).

 

6. Compile the addin(if you don't set the Build output path above, just manually copy the binary to the Inventor Bin folder).

7. Launch Inventor.

8. In VS, Tools->Attach to Process…->choose Inventor.exe->Attach.

 

Now you can add breakpoint in your addin project, and debug it. Hope it helps.

 

Please let me know if any questions.



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 19
YuhanZhang
in reply to: YuhanZhang

I want to update the steps as below which maybe more convenient:

 

  1. Install Inventor wizard from SDK.
  2. Open Visual Studio, new an Inventor addin with template.
  3. Add you code to addin.
  4. Copy the .addin file to proper location according to step #3) in Readme.txt.
  5. Do either change of below two to make sure the .addin has the assembly path point to your binary:
  • Edit the .addin file, and change the assembly path to the full path of your binary being created: <Assembly>[binary full path here]</Assembly>.
  • Or in VS, open the project Properties(Project->[project name] Properties), on Compile tab, set the Build output path: to the Inventor Bin folder(C:\Program Files\Autodesk\Inventor [version]\Bin).

6. In VS, open the project Properties(Project->[project name] Properties), on Debug tab, set the Start external program: to the Inventor.exe path.

7. Set breakpoint in addin code and debug your project(Debug->Start debugging F5).

 

This will start the external program and attach to it so need not to attach the process manually after launching it.



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 4 of 19
sellis
in reply to: YuhanZhang

First I reset all settings in VS2010

Added code consists of a message box at end of StandardAddInServer.Activate.

Code runs fine outside VS2010

 

When debugging from VS breakpoints in StandardAddInServer.Activate work on load.

After Inventor starts and I move the mouse I get “DisconnectedContext was detected”

“Context 0x302278' is disconnected.  Releasing the interfaces from the current context (context 0x301f00).This may cause corruption or data loss. To avoid this problem, please ensure that all contexts/apartments stay alive until the applicationis completely done with the RuntimeCallableWrappers that represent COM components that liveinside them.”

 

Immediate window has lots of errors and warnings while loading like...

“System.Windows.Data Error: 39 : BindingExpression path error: 'Id' property not found on 'object' ''InvFlowRibbonPanel' (HashCode=24807479)'. BindingExpression:Path=Id; DataItem='InvFlowRibbonPanel' (HashCode=24807479); target element is 'KeyboardActivatableToggleButton' (Name='PART_CollapsedPanelButton'); target property is 'AutomationId' (type 'String')”

  

I was getting this problem before in IV2012 while trying to debug com registered dll. Any ideas?

 

Thanks

Stan

Message 5 of 19
fjrg1979
in reply to: sellis

Same issues here. This wasn't a problem with Inventor 2011. Looks like this is something Autodesk overlooked. I can attach to the process manually but it's a bit of a pain. I'm getting a similar disconnected context error when having VS2010 start an external program (Inventor 2012).

Message 6 of 19
VidarDK
in reply to: fjrg1979

The suggested solution does not work Smiley Sad

Same problem in VS2008 as well.

Message 7 of 19
YuhanZhang
in reply to: VidarDK

Can you add a simple addin project that I can debug to see the problem you encountered. I guess you have added some content that I did not. And please add detailed steps if you think it is necessary for me to follow.



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 8 of 19
VidarDK
in reply to: YuhanZhang

I made this simple addin with a ribbonbar and a button, when I debug and click on the ribbonbar/button I get the error: “DisconnectedContext was detected”

 

Message 9 of 19
YuhanZhang
in reply to: VidarDK

Please try the attached one. Modify the .addin file to update the Assembly path to the full file name of the .\Addin\BWEdocxInventor2012Vault\bin\Debug\BWEdocxInventor2012Vault.dll.



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 10 of 19
VidarDK
in reply to: YuhanZhang

Sorry for the late reply, I've been on vacation.

I've tried the attached addin, and modified the addin file - I still get the error: “DisconnectedContext was detected” Smiley Sad

Please provide a solution - this is very important to me.

Message 11 of 19
YuhanZhang
in reply to: VidarDK

Can you share more info that which step you encounterred this error. Did you debug into the breakpoint?



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 12 of 19
VidarDK
in reply to: YuhanZhang

If i debug your code it goes into the breakpoint, but when i step to linie 66 i get the error below (I'm running a 64-bit windows XP and VS2010 SP1).

No Source Avaiable

Call stack location:
msvcm90.dll!<CrtImplementationDetails>DoDllLanguageSupportValidation() Line505

Source file information:
Locating source for 'f:\dd\vctools\crt_bld\self_64_amd64\crt\src\minternal.h'. Checksum: MD5 {35 fe 78 dc 38 4e b df 99 82 ab 9 9a ba 9d 2f}
The file 'f:\dd\vctools\crt_bld\self_64_amd64\crt\src\minternal.h' does not exist.
Looking in script documents for 'f:\dd\vctools\crt_bld\self_64_amd64\crt\src\minternal.h'...
Looking in the projects for 'f:\dd\vctools\crt_bld\self_64_amd64\crt\src\minternal.h'.
The file was not found in a project.
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\crt\src\'...
Source was found at 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\crt\src\minternal.h'.
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\src\mfc\'...
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\src\atl\'...
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\'...
Determining whether the checksum matches for the following locations:
1: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\crt\src\minternal.h Checksum: MD5 {c9 db 5a 4a a1 c7 49 7b 27 a6 a7 b4 4b e7 a d} Checksum doesn't match.
The debug source files settings for the active solution indicate that the debugger will not ask the user to find the file: f:\dd\vctools\crt_bld\self_64_amd64\crt\src\minternal.h.
The debugger could not locate the source file 'f:\dd\vctools\crt_bld\self_64_amd64\crt\src\minternal.h'.

 

When i insert addtional code eg. a simpel MsgBox and try to debug i still get the error: “DisconnectedContext was detected”

    Public Sub m_featureCountButtonDef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_featureCountButtonDef.OnExecute
      MsgBox("Hello", MsgBoxStyle.Information)
    End Sub

 




 

Message 13 of 19
sellis
in reply to: YuhanZhang

Been busy so just getting back to this... 

 

64-bit win7 and VS2010

Tried out the posted addin sample. Can step through Activate and Inventor finishes loading. When I move the mouse over Inventor I get -

DisconnectedContext was detected
Message: Context 0x3ac0f8' is disconnected.  Releasing the interfaces from the current context (context 0x3abd80).This may cause corruption or data loss. To avoid this problem, please ensure that all contexts/apartments stay alive until the applicationis completely done with the RuntimeCallableWrappers that represent COM components that liveinside them.

 

Stan

Message 14 of 19
VidarDK
in reply to: sellis

I have found a solution to the problem.
In VS2010 under Debug, Exceptions ...
remove checkmark from ContextSwitchDeadlock and DisconnectedContext.

Image.jpg

Message 15 of 19
sellis
in reply to: VidarDK

This worked on the sample addin but...

 

When I tried debugging a very complex project "Visual Studio Remote Debugging Monitor" runs one CPU at 100% as soon I open a drawing. This project runs fine when not debugging.

 

Stan

Message 16 of 19
ADNpati
in reply to: YuhanZhang

HEllo Rocky

 

 

I Got everythig  correct, but I can't find .addin file in my project folder...

 

can you please point out me in corrct way.. pleaseSmiley Sad  Smiley Sad   Smiley Sad  Smiley Sad

Mechanical Engineer
Inventor Applications Engineer

--------------------------------------------------------------------------------------

If my solution seems to remedy your problem, please press the Accept Solution button, Some KUDOS -

-------------------------------------------------------------------------------------
Message 17 of 19
YuhanZhang
in reply to: ADNpati

When you use InventorWizards to create your addin project, you can find the .addin file in the project folder. Can you share more info about your situation? Like which Inventor you use, and in which language you create  your addin, and the VS version.



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 18 of 19
ADNpati
in reply to: YuhanZhang

Hello Rocky,

 

Thanks Mate for replies.

 

I found a way tofix the above issue with your post and updated in this thread.

i Got 2 Main questions in my head

 

1.   But I see there are two types of templates to use for VS2010. one is Autodesk Inventor AddIn (old Template) and Autodesk Inventor 2013 AddIn (updated).

     I am Using Autodesk FDS 2013 Premium and VS2010 Express with SP1 and with Windows SDK for .Net 4.

     There are .maifest errors when I use updated templates and no errors with old templates.

    Why is That?????????

 


2.   when I am debugging a simple module, VS2010 is opening Inventor and after i opening an assembly it is doing nothing.    Is there something that I am missing??? (fixed debug procedire foro express versions)

 

3.   How to get addin Button on to Auodesk Invedntor User interface??? so to use directly from Inventor

 

Thanks in Advace ffor your unlimited patience.

will wait on repply.

 

cheers.

Mechanical Engineer
Inventor Applications Engineer

--------------------------------------------------------------------------------------

If my solution seems to remedy your problem, please press the Accept Solution button, Some KUDOS -

-------------------------------------------------------------------------------------
Message 19 of 19
YuhanZhang
in reply to: ADNpati

My answer are as below:

 

1. From Inventor 2013 we merged the InventorWizards installer to DeveloperTool.msi, and make sure we can install the DeveloperTools side by side with previous ones, so you can see the different versions of Inventor wizards templates, and the updated wizards template will have the latest Autodesk.Inventor.Interop.dll referenced if the VS supports(like VS2010 supports Inventor 2003).

 

As for the error, can you copy the error info here?

 

2. If I understand right, you mean you used the VS2010 to launch Inventor during debuged it, and then it did run into the code when you open an assembly document? Can you double check that you have the .addin file copied to proper folder, and set the Dll path in the .addin correctly? You can get help from the Readme.txt file in the addin project to know where to copy the .addin.

 

3. You can create your own controls on Ribbon in the addin project, you can find sample in SDK (like SimpleAddin : C:\Users\Public\Documents\Autodesk\Inventor 2013\SDK\DeveloperTools\Samples\VB.NET\AddIns\SimpleAddIn) with the source code.



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.

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

Post to forums  

Autodesk Design & Make Report