none
Can an extension inject an assembly / .dll into the debuggee? RRS feed

  • Question

  • Hi,

    as a workaround for this issue:

    https://developercommunity.visualstudio.com/content/problem/68105/debuggertypeproxy-attribute-in-autoexpcs-doesnt-wo.html

    I have created an extension, that injects an assembly into the debuggee by evaluating an expression with this code:

                string expressionString = string.Format("System.Reflection.Assembly.LoadFile(@{0})", StringUtilities.SurroundWithQuotes(filePath));
                Expression expression = _dte.Debugger.GetExpression(expressionString);
                string expressionValue = expression.Value;

    which enables the use of  the DebuggerTypeProxyAttribute (on the assembly level) in an arbitrary assembly. This works fine in VS2017, but returns 'Internal error in the expression evaluator.' in VS2019.

    So, my question is: Is there an API/VS-Interface that allows to load an assembly into the debbuggee?

    I could not find a suitable method on IVSDebugger,  IVSDebugger2, IVSDebugger3, ....


    P.S: When I manually add the same expression in a watch-window, it works and loads the assembly into the debuggee.
    • Edited by Frank K. (LS) Friday, June 7, 2019 8:46 AM added P.S.
    Friday, June 7, 2019 6:29 AM

All replies

  • Hi Frank,

    Welcome to MSDN forum.

    Sorry but I haven't found the API which satisfy your needs.

    But as you mentioned above, your extension once works in VS2017 but not in VS2019. Maybe it has something to do with these two debug options(Debug menu=>Options):

    In VS2019, these two options are disabled by default, please enable them and check if it helps.

    Any update please feel free to contact me.

    Best Regards

    Lance


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, June 7, 2019 8:43 AM
  • Hi Lance,

    these two options are disabled in my VS2017 settings, too. And since the expression works when it is executed in a watch-window (I added this info just before just answered, so you probably haven't seen it), I suspect a timing/threading issue in VS2019 or something has changed in the workings of Dte.Debugger.GetExpression.

    Friday, June 7, 2019 9:00 AM
  • Hi Frank,

    Sorry for the delay. Please check if you've updated every prerequisite during the migration from VS2017 to VS2019.

    And as you mentioned above there might be a timing or threading issue, please try disabling any other extension except that one, and create a new project to test. Also, have you tried a VS repair.

    Please let me know if all above not helps, I'm trying to get someone experienced in this topic to research, it may take some time. Sorry for the inconvenience and thanks for your understanding!

    Best Regards

    Lance


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, June 10, 2019 10:17 AM
  • Good news: my workaround (evaluating an expression) suddenly started working again...

    Bad news: I have no idea why...

    But I still would be interested if injecting is possible through the extensibility-API (maybe with IDebuggerInternal).

    Wednesday, July 17, 2019 12:31 PM