Hi!
I'm a Revit API noob trying to go through AdnRevitApiLabsXtra self-learning course and I stumbled upon an issue I can't seem to find a solution to using good'o uncle google. With the initial VS setup, I was unable to get access to my local variables during debugging. It looked more or less like this:
After following some instructions I found on the web I managed to make the variables visible (by enabling Tools->Options->Debugging->General->"Use Managed Compatibility Mode") but now my VS keeps crashing if I try to click on the variables' details after hovering the mouse over it (The debugger's worker process (msvsmon.exe) unexpectedly exited). When I expand details in the "locals" window this worrying message is visible here:
Anyone's got some ideas on how to solve this? I have a feeling like I should be able to access this data if I want to learn anything.
Cheers,
Patryk
Afaict, you seem to be facing two separate issues and struggling with both at the same time:
I would suggest that you use the SharpDevelop IDE (integrated development environment) provided by the built-in Revit macro functionality to focus on the first issue first, and worry about the second issue sometime later, and separately.
I hope this helps.
Cheers,
Jeremy
Another suggestion...
Work through the C# video series for absolute beginners. I'm halfway through it. It's very well done and it's free.
I also recommend the "My First Revit Plugin":
It looks to me like your public class needs a name. Something like:
"public class Class1: Autodesk.Revit.UI.IExternalCommand"
You have "public class Command...." and command is a keyword, so it can't be used for a class name.
Thank you all for the responses! I'm pleasantly surprised by receiving useful feedback so quickly.
I guess, my issue is not an easy one to solve. As soon as I figure it out, I'll post what was the problem.
@jeremytammik I'll take a look into SharpDevelop IDE. Thank you for your suggestion.
PS. Thank you so much for sharing so much self-learning material on API. I'm writing a thesis which includes developing a Revit Add-on and I doubt it would be possible without your work.
@stever66 wrote:
I also recommend the "My First Revit Plugin":
It looks to me like your public class needs a name. Something like:
"public class Class1: Autodesk.Revit.UI.IExternalCommand"
You have "public class Command...." and command is a keyword, so it can't be used for a class name.
I finished the "my first plugin" tutorial about half a year ago.
About the class name - the "Command" part of the class name comes from Jeremy's VS Revit Template for C#. I tried changing it, as you suggested, though, and nothing changed, unfortunately.
I reinstalled VS but that gave no results. What makes things more interesting is that there is no issue with lack of access to the variable values while debugging a "regular code" which is not Revit-related. Maybe reinstalling Revit will help?
I'm a noobie to C# but I seriously doubt the problem will be resolved by reinstalling Revit. Can you post your code so I can copy and paste it along with the exact error you're receiving?
Sure!
#region Namespaces using System; using System.Collections.Generic; using System.Diagnostics; using Autodesk.Revit.ApplicationServices; using Autodesk.Revit.Attributes; using Autodesk.Revit.DB; using Autodesk.Revit.UI; using Autodesk.Revit.UI.Selection; #endregion namespace IntroCs2 { /// <summary> /// Hello World #1 - A minimum Revit external command. /// </summary> [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.ReadOnly)] public class YellowWorld : Autodesk.Revit.UI.IExternalCommand { public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { //breakpoint here Autodesk.Revit.UI.TaskDialog.Show( "My Dialog Title", "Hello World!"); return Autodesk.Revit.UI.Result.Succeeded; } } }
The class name did not match between the code and the solution explorer. Once I changed it in the code it worked fine. Don't rename the file in the solution explorer or you'll have all sorts of new problems. See attached image.
I changed it to the same name in the solution explorer as well as the manifest file on mine PC. I've sent you only the source code, so that wasn't apparent. The code runs correctly for me too. The problem is not being able to access the variables while debugging. I had the same problem when the class was called command. I changed it since someone I got a suggestion to do so in one of the previous posts. I appreciate your initiative, though!
Make sure you have at least one breakpoint then go to Debug/Windows/Watch/ Watch 1... While debug is running. See attached image.
The Watch 1 window is open when debugging as well as the Locals window so the suggested solution doesn't do much. Both of these windows just don't show the variable values or show them with an error if I enable the "use compatibility mode". Like in the 2 first screenshots in this thread
Ignoring the de-bugging features for a second, can you build the program and get it to run from within Revit?
Also have you made sure the version of .Net you are using matches the Revit release you are using. And that you have checked that the RevitAPI and RevitAPIUI references are loaded from the correct version of Revit?
@stever66 wrote:
Ignoring the de-bugging features for a second, can you build the program and get it to run from within Revit?
Yes. I get the Hello World window.
@stever66 wrote:Also have you made sure the version of .Net you are using matches the Revit release you are using. And that you have checked that the RevitAPI and RevitAPIUI references are loaded from the correct version of Revit?
Good point! The .Net version I had active was 4.7.2. Hence - once I realised that - I changed it to 4.7 right away but to my disappointment that did not help my problem.
The references are located in the Revit 2019 folder, which is the one I use.
I was just looking through the Revit 2019 developers help, and in about 3 places I have seen this or something similar;
The following instructions apply to Visual Studio Professional. The relevant option is not available in the Visual Studio Express editions.
MS Visual Studio 2015 Express Edition (C# or VB.NET). Microsoft Visual Studio 2015 Professional is recommended, though, as Express editions do not support DLL debugging. Alternatively, you can use the built-in SharpDevelop development environment in Revit.
I’m sure this hasn’t been in earlier versions of Revit developers help. Is this something new for VS? VS no longer includes debugging on the express version? Or is it a limitation that the latest version of Revit has caused?
Could this be your problem?
I'm using VS 2017 Community. Maybe the Revit version is the issue (I'm running Revit 2019) but I haven't tested it yet.
What was interesting for me to find out was that once my supervisor had shown me how does his debugging work I noticed that at his working station (with Revit 2018) there is the same "Could not evaluate expression" message in the "locals" window. That would mean that this is a common issue, I guess. What surprised me though, was that he doesn't get the "The debugger's worker process (msvsmon.exe) unexpectedly exited" after hovering the mouse over commandData and looking into its details.
I decided to keep on working in VS ignoring this bug since I am still able to review variables created by myself during debugging.
Can't find what you're looking for? Ask the community or share your knowledge.