"Could not evaluate expression"

Anonymous

"Could not evaluate expression"

Anonymous
Not applicable

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:
unknown.png

 

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:

unknown (1).png

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

0 Likes
Reply
3,750 Views
15 Replies
Replies (15)

jeremytammik
Autodesk
Autodesk

Afaict, you seem to be facing two separate issues and struggling with both at the same time:

 

  • Learning the Revit API
  • Struggling with Visual Studio

 

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

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes

62BJW
Advocate
Advocate

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.

 

https://mva.microsoft.com/en-us/training-courses/c-fundamentals-for-absolute-beginners-16169?l=p90Qd...

stever66
Advisor
Advisor

I also recommend the "My First Revit Plugin":

 

https://knowledge.autodesk.com/support/revit-products/learn-explore/caas/simplecontent/content/my-fi...

 

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.

 

0 Likes

Anonymous
Not applicable

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":

 

https://knowledge.autodesk.com/support/revit-products/learn-explore/caas/simplecontent/content/my-fi...

 

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.

 

Przechwytywanie.JPG

0 Likes

Anonymous
Not applicable

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?Przechwytywanie.JPG

0 Likes

62BJW
Advocate
Advocate

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?

0 Likes

Anonymous
Not applicable

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;

        }
    }
}
0 Likes

62BJW
Advocate
Advocate

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.

0 Likes

Anonymous
Not applicable

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!

Przechwytywanie.JPG

0 Likes

62BJW
Advocate
Advocate

Make sure you have at least one breakpoint then go to Debug/Windows/Watch/ Watch 1... While debug is running. See attached image.

0 Likes

Anonymous
Not applicable

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

0 Likes

stever66
Advisor
Advisor

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?

0 Likes

Anonymous
Not applicable

@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.

0 Likes

stever66
Advisor
Advisor

I was just looking through the Revit 2019 developers help, and in about 3 places I have seen this or something similar;

 

Debugging Your Application in Microsoft Visual Studio

The following instructions apply to Visual Studio Professional. The relevant option is not available in the Visual Studio Express editions.

 

 

  1. 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?

 

 

 

Anonymous
Not applicable

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.

0 Likes