Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug C# dll when loaded into powershell's process? Is it even possible?

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.

like image 854
naeron84 Avatar asked Nov 09 '11 08:11

naeron84


1 Answers

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.

like image 105
Paolo Tedesco Avatar answered Oct 03 '22 13:10

Paolo Tedesco