debugging mode with visual studio Breakpoint

debugging mode with visual studio Breakpoint

amir.aroesti
Advocate Advocate
2,761 Views
7 Replies
Message 1 of 8

debugging mode with visual studio Breakpoint

amir.aroesti
Advocate
Advocate

Hi ,

i get in trouble while trying to go through lesson 4 .

i succeed to lunch up revit in "Start External Program".

The AddIn manifest file is up-to-date to right location.

Then i chose line with breakpoint but when i start debugg the visual studio doesn't stop to "Step By Step" at any line, it just go through it and pass over.

 

any update on this lesson? i try to find the best way to pass through the code and find out some bugs .

 

Thanks in advance

 

0 Likes
Accepted solutions (1)
2,762 Views
7 Replies
Replies (7)
Message 2 of 8

RPTHOMAS108
Mentor
Mentor

Lack of hitting break points usually indicates you are pointing to wrong assembly location or VS isn't attached to the process.

Check:

Build > Configuration Manager

Has 'Active solution configuration' set to Debug

Check:

Path of the dll file location in manifest file (.addin) is matching relative 'Output path' on Build Tab within the properties of your visual studio solution. The path saved in the sample may not be where you saved the project solution. Although I would have expected you to get an error if the assembly file wasn't found.

0 Likes
Message 3 of 8

amir.aroesti
Advocate
Advocate

@RPTHOMAS108  thanks for respond

i have just double check what you mention in your comment.

 

i make sure the manifest file point to the correct address and check about the configuration manager.

see the attached picture.

 

the breakpoints doesn't stop the code and its just pass through it.

any other ideas??

 Amir

2020-06-09 22_40_41-Autodesk Revit 2020.2 - [Project1 - Section_ Section 1].png2020-06-09 22_41_15-Tidhar - Notepad.png2020-06-09 22_41_53-MyRevitCommands (Running) - Microsoft Visual Studio.png2020-06-09 22_46_57-MyRevitCommands - Microsoft Visual Studio.png2020-06-09 22_47_25-MyRevitCommands - Microsoft Visual Studio.png

2020-06-09 22_56_45-MyRevitCommands - Microsoft Visual Studio.png

0 Likes
Message 4 of 8

RPTHOMAS108
Mentor
Mentor
Accepted solution

You are creating a .Net Standard library. Do you require cross platform support or are you not using Windows?

 

https://docs.microsoft.com/en-us/visualstudio/debugger/troubleshooting-breakpoints?view=vs-2019

 

The main suggestions above are to try alternative break point positions or turn off 'Optimise code' on the build tab. I'm not that familiar with .Net Standard so I don't know if there are any specific peculiarities with that which may need to be accounted for.

 

The lesson you mention has a project solution associated with it but that is not what you are using so you are not following lesson 4 as such.

 

0 Likes
Message 5 of 8

amir.aroesti
Advocate
Advocate

Thank you so much !!! @RPTHOMAS108  ,

i wasted  too much time on that issue!

the things is probably due to the ".Net Standard" . i guess it because this is my first plug in and i missed something on the guide and chose a wrong framework.

i dont know how to fix it up so i start over a new project step by step and finally success!!

 

due to the so exhausting process i am looking for a better way to go through the code step by step without using the debugging mode because it takes a lot of time to run Revit each time. 

i thought about maybe "writing" each step in some TXT file due to running the code and if the code will fail i will go through the TXT file looking for the failure point.

how that sound? any other idea?

0 Likes
Message 6 of 8

lukaskohout
Advocate
Advocate

The easiest way is to use AddinManager. This way you do not have to stop the running instance of Revit, this addin loads the DLL on the go. You just need to re-attach VS to the Revit process after rebuild.

 

AddinManager is part of Revit SDK.

 

I would recommend always using VS to debug, since you can go through the values currently available in the debugged code and see what you can get from the code and what you cannot


Hitting Accepted Answer is a Community Contribution from me as well as from you.
======================================================================
0 Likes
Message 7 of 8

amir.aroesti
Advocate
Advocate

Hi @lukaskohout 

 

of course, usually i use AddinManager but there the code just failed without giving me specific information on where and why.

 
 
 
 
 
0 Likes
Message 8 of 8

RPTHOMAS108
Mentor
Mentor

There are various method for debugging without starting Revit although I have to admit I usually just restart Revit.  Debug code stepping is something you do when you believe it works because you have already manually gone through the various code paths i.e. it is a surprise when something doesn't so you step through to understand why.

 

The usual requirement to restart is that the .dll file becomes locked so can't be recompiled. If you load .dll at runtime (Assembly.LoadFrom) from within your main add-in assembly you can create an instance of your IExternalCommandClass  (System.Activator.CreateInstance) then run Execute by passing the command data from your main assembly through (the one that becomes locked). I believe this is probably similar to what the Addin manager does. The approach has implication for Extensible storage and other features where the Add-in/Vendor ID is used.

 

0 Likes