2

To put it simply. I have a very simple class for testing purposes. I am trying to debug it from inside Powershell which should call the Visual Studio 2017 debugger.

Class:

namespace ClassLibrary1
{
    public class Class1
    {
        public static void MyMethod()
        {
            Console.WriteLine("method called successfully");
        }

        public static void SecondMethod()
        {
            Console.WriteLine("second method called successfully");
        }

        public void ThirdMethod()
        {
            Console.WriteLine("this method is instantiated");
        }
    }
}

Adding assembly in Powershell

Add-Type -Path "C:\Users\Administrator\ClassLibrary1\bin\Debug\ClassLibrary1.dll"

Then I attach the debugger to Powershell process in Visual Studio 2017. But I am getting this in visual studio when I execute the code in powershell:

Your app has entered a break state, but no code is currently executing that is supported by the selected debug engine (e.g. only native runtime code is executing).

When I attach the debugger to PS Process I get this in the output window:

The thread 'Pipeline Execution Thread' (0xf68) has exited with code 0 (0x0).
The thread '<No Name>' (0x19c8) has exited with code 0 (0x0).
The thread '<No Name>' (0x255c) has exited with code 0 (0x0).
The thread '<No Name>' (0x2690) has exited with code 0 (0x0).
The thread '<No Name>' (0x2434) has exited with code 0 (0x0).
The thread '<No Name>' (0x20b8) has exited with code 0 (0x0).
The thread '<No Name>' (0x2280) has exited with code 0 (0x0).
The thread '<No Name>' (0x212c) has exited with code 0 (0x0).
The thread '<No Name>' (0x222c) has exited with code 0 (0x0).

When I execute the method in PowerShell, in VS Output window I get the following:

Exception thrown: 'System.Management.Automation.Host.HostException' in System.Management.Automation.dll
The thread 'Pipeline Execution Thread' (0x2b88) has exited with code 0 (0x0).
Exception thrown: 'System.Management.Automation.PSNotImplementedException' in System.Management.Automation.dll
The thread 'Pipeline Execution Thread' (0x1d48) has exited with code 0 (0x0).
The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

I click on Continue Execution button/link and Visual Studio and Powershell ISe become non-responsive.

I have unchecked the "Just My code". Can someone tell me what to do?

Burre Ifort
  • 653
  • 3
  • 15
  • 30
  • You may need create helper class in your library when you call the method from PowerShell? https://stackoverflow.com/a/8063356/9125096 – Fletcher Mar 01 '18 at 07:58
  • I just started getting this error today after I made some changes. Not using PowerShell, backed out all my changes, reboot, clean, rebuild all, still getting it. Argh! – JulieC Nov 13 '18 at 22:50

0 Answers0