"Object reference not set" in Powershell tools 4.9.1

Issue #175 resolved
palandri@4j.lane.edu created an issue

VS2017 Pro 15.9.15.

After upgrading Powershell Tools to 4.9.1, get the following error when trying to copy text from Powershell Interactive Window:

“Object reference not set to instance of an object.”

This happens when trying to copy with Right-click-Copy, or Ctrl-C mapped to Edit-Copy.

I enabled debugging, generated the error, and attached the log file.

Comments (2)

  1. Nick De Lancie

    For VS Community 2019 v. 16.2.3 | PoshTools v. 4.9.1 (not Pro) | $PSVersionTable at end

    I recently updated PoshTools to the new version as well.

    I noticed issues in the PowerShell Interactive Window using the both the Context Menu copy function (RightClick y) and with Ctrl+C (globally mapped in VS to Edit.Copy), but not exactly as you have reported--for me the issue is more nuanced, as set out below. However, I hadn’t yet got to posting this as an issue. Thank you for doing so.

    Previously, before the v. 4.9.1 upgrade, Ctrl+C worked in neither location in the PowerShell Interactive Window, but RightClick y worked in both locations. By locations in the PowerShell Interactive Window, I mean (1) the current line(s) of text being typed at the prompt before an “enter” that generates a new prompt (including a line that was (or lines that were) previously typed that is (or are) restored to the current prompt by up or down keys) (“Current Text"); and (2) everything above that in the PowerShell Interactive Window (i.e., prior user typed line(s) at the prompt and output from PowerShell, including code output, error messages, etc.) (“Prior Text”).

    (To be clear, the issues here are only in the PowerShell Interactive Window, not in the VS code editor windows.)

    Here is what I now experience with v. 4.9.1:

    • For Current Text, both Ctrl+C and RightClick y work to copy the selected text as expected. (Thus, the prior issue in Current Text with Ctrl+C--at least for me--has been fixed.)
    • For Prior Text, Ctrl+C does nothing at all--whatever text, if any, that was previously on the ClipBoard remain there. (Thus, the prior issue in Prior Text with Ctrl+C remains unfixed.)
    • For Prior Text, RightClick y causes Visual Studio to throw the “Object reference not set to instance of an object.” error in an OkOnly dialog box. (Thus, previously working RightClick y in Prior Text is now broken.)

    \$PSVersionTable:

    Name                                      Value
    ----                                          -----
    PSVersion                                5.1.15063.1805
    PSEdition                                 Desktop
    PSCompatibleVersions            {1.0, 2.0, 3.0, 4.0...}
    BuildVersion                            10.0.15063.1805
    CLRVersion                              4.0.30319.42000
    WSManStackVersion               3.0
    PSRemotingProtocolVersion   2.3
    SerializationVersion                 1.1.0.1

  2. Log in to comment