Visual Studio Developer Center > Visual Studio Forums > Visual Studio Debugger > Immediate Window -- Is it possible to create an expression evaluator at runtime?
Ask a questionAsk a question
 

QuestionImmediate Window -- Is it possible to create an expression evaluator at runtime?

  • Tuesday, October 27, 2009 9:49 PMFasttimes Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    For debugging I'd like the ability to have something like the immediate window where I can evaluate expressions.  For example, say I have a collection called foobar, I would like to be able to send a command to some function and have the result returned

    eg.

    dim result as string = xxxx.evaluate("foobar.count")

    Anyone know a way to accomplish something like this?

All Replies

  • Wednesday, October 28, 2009 8:36 AMRoahn LuoMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hello,

    Yes, it's possible. Visual Studio will call IDebugParesedExpression interface when we enter an expression we want to watch. During this process, the expression will be parsed to tokens by using the function Tokenize(). Symbol Provider provides the information needed and finally, it returned a IDebugProperty2 object which contains value and type of the expression.

    For more guidance, I recommend you refer to 'Writing a Common Language Runtime Expression Evaluator':
    http://msdn.microsoft.com/en-us/library/bb161694(VS.80).aspx


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback, please tell us.
    Welcome to the All-In-One Code Framework!
  • Wednesday, October 28, 2009 8:39 AMFasttimes Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I read that already, but its pretty sparse of details.  They refer to sample code, but they dont even tell you how to access the code.  Any hints on how to get this?

  • Wednesday, October 28, 2009 9:09 AMRoahn LuoMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi,

    The VSIP SDK for Visual Studio 2005 could be download at:
    http://www.microsoft.com/downloads/details.aspx?familyid=94c9970d-c247-4ded-a76d-f7b3d589e71d&displaylang=en

    After downloading and unzipping the file, run the Setup.exe, we'll get the sample in the corresponding folder.

    Best regards,


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback, please tell us.
    Welcome to the All-In-One Code Framework!
  • Wednesday, October 28, 2009 9:18 AMFasttimes Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thanks, however that setup wont run as it requires VS 2003 installed.  A tad outdated?  Is there a way around this?

    Ok, I used MSEXEC to extract, however the solution mentioned in the article wont compile.

    Have you actually seen this work with VS 2008?  I cant find any references to anyone else using that interface.
  • Thursday, October 29, 2009 4:35 AMRoahn LuoMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hello,

    Yes, by default, it required VS2003, I'm sorry for the inconvinience.
    I think that because the project is created in it when writing the MSDN aritcle, hence, when we open it in VS 2008, the settings is completely different. However, Visual Studio 2008 will automatically convert the version when openning the solution.
    To make it work with VS2008, we need to make the settings for the project right, for example, the directory containing the source, or else, there will be build errors.

    Best regards,


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback, please tell us.
    Welcome to the All-In-One Code Framework!