Debug C# dll when loaded into powershell's pro

2019-01-23 16:58发布

I have a powershell script and I load a dll via [Reflection.Assembly]::Load

I want to place brakepoints into the source code of that dll, add watches etc.

Attaching to the powershell process didn't work (actually I tried the powershell ise). There are no other processes to attach to. Any ideas? Once an exception (it's my exception, so this supposed to happen) appeared in VS but I couldn't reproduce it.

1条回答
我只想做你的唯一
2楼-- · 2019-01-23 17:46

As an alternative, you could create an helper class in your library:

namespace Something {
    public static class DebugHelper {
        public static void AttachDebugger() {
            System.Diagnostics.Debugger.Launch();
        }
    }
}

Then, you can call that method from PowerShell, and you will get the debugger attached.

查看更多
登录 后发表回答