Watch High Resolution video on AR-CAD
If you have followed my earlier screen casts on Developing Inventor Addin using C# (Visual Studio) here and here, I had not touched anything on How to debug an Addin using Visual Studio. When you build / register an Addin, a DLL (Dynamic Link Library) file is created which Inventor identifies as an Addin. To be able to debug an Addin, you have to step into Inventor Process. This can be done as follows.
If you are using a free version of Microsoft Visual Basic (Express Edition), it does not have a debugging option for COM objects out of the box. This can be done with the following work around / trick
- Create a file with a name <yourAddinDllName>.csproj.user (In my case, it is AR-CADInventorAddIn4.csproj.user
- Put the following content into this file (The only thing that could probably change is the location of your Inventor.exe file)
<Project xmlns=”http://schemas.microsoft.com/developer/msbuild/2003″>
<PropertyGroup Condition=” ‘$(Configuration)|$(Platform)’ == ‘Debug|AnyCPU’ “>
<StartAction>Program</StartAction>
<StartProgram>C:Program FilesAutodeskInventor 2008BinInventor.exe</StartProgram>
</PropertyGroup>
<PropertyGroup>
<ProjectView>ShowAllFiles</ProjectView>
</PropertyGroup>
</Project>
- Close the solution and open it again. By doing this, the .csproj.user file is associated with the project.
- Insert a “Break Point” in your code and Start Debugging by hitting F5 key.
- Now Inventor gets started and you are halted at the break point. Use Step Through and Step Into to inspect different objects, by hovering the mouse over the objects.
- When you are done with Debugging, your addin would load up and hence Inventor is loaded completely. You can also insert break points when you click on a Custom Button , your addin has created when the Inventor is loaded completely.
If you happen to have a Visual Studio Professional version, there is no need to create the .csproj.user file, you can follow these instructions to get the debugger working.
- Right Click on your addin project. Go to its properties.
- Go to Debug Tab listed in the left side of this dialog.
- Set Configuration = Debug , Platform = Any CPU
- Set Start External Program to the location pointing to Inventor.exe
- Close the properties Dialog box
- In the Solutions Explorer, click on an icon “Show All Files”
- Carry on with your debugging session as explained above and also in the screencast
I hope things are pretty much clear, if there are any queries, I would love to hear them in the form of comments.