调试C#DLL时加载到PowerShell中的进程?它甚至有可能? [英] Debug C# dll when loaded into powershell's process? Is it even possible?
问题描述
我有一个PowerShell脚本和我加载通过[Reflection.Assembly] ::加载DLL
I have a powershell script and I load a dll via [Reflection.Assembly]::Load
我要放置brakepoints到该DLL的源代码,添加监视等。
I want to place brakepoints into the source code of that dll, add watches etc.
附加到PowerShell进程没有工作(其实我试过PowerShell ISE中)。有没有其他进程重视。有任何想法吗?一旦异常(这是我的异常,所以这应该发生的)出现在VS,但我无法重现它。
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.
推荐答案
作为替代方案,你可以在你的库中创建一个辅助类:
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();
}
}
}
然后,您可以调用从PowerShell的方法,你会得到调试连接。
Then, you can call that method from PowerShell, and you will get the debugger attached.
这篇关于调试C#DLL时加载到PowerShell中的进程?它甚至有可能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!