调试C#DLL时加载到PowerShell中的进程?它甚至有可能? [英] Debug C# dll when loaded into powershell's process? Is it even possible?

查看:164
本文介绍了调试C#DLL时加载到PowerShell中的进程?它甚至有可能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆