相关疑难解决方法(0)

如何以编程方式在与父项相同的Visual Studio调试会话中启动子进程?

在调试器下运行进程时,我想在同一个调试器中启动子进程.

目前,我用

Process.Start("sample.exe");
Run Code Online (Sandbox Code Playgroud)

我希望它是这样的:

if (Debugger.IsAttached)
    // start "sample.exe" in the same debugging session
else
    Process.Start("sample.exe");
Run Code Online (Sandbox Code Playgroud)

我可以将一个标志传递给指示它调用的子进程Debugger.Launch(),但这不会捕获启动错误,并且会导致调试会话中某些功能未启用(例如编辑和继续等).调试器最好直接启动进程.

.net c# debugging visual-studio

21
推荐指数
1
解决办法
1万
查看次数

以编程方式在Visual Studio中应用/停用断点

无论可能实现相同结果的其他选项(即手动添加断点),是否可以以编程方式将断点添加到Visual Studio项目的源代码中?

如:

try
{
    FunctionThatThrowsErrors(obj InscrutableParameters);
}
catch(Exception ex)
{
    Log.LogTheError(ex);
    AddBreakPointToCallingFunction();
}
Run Code Online (Sandbox Code Playgroud)

这样,当您下次运行调试时,它将自动在上次运行中导致故障的所有点上设置断点.

我不是说这是一种特别有用的调试方式.我只是想知道能力是否存在.

.net c# breakpoints visual-studio

17
推荐指数
2
解决办法
9194
查看次数

.NET Core 中是否有 System.Runtime.InteropServices.Marshal.GetActiveObject() 的替代品?

该方法GetActiveObject()在 .NET Framework 中可用System.Runtime.InteropServices.Marshal,但在 .NET Core 中不可用(/sf/answers/4060761701/)。

如果我想使用 .NET Core(来自 PowerShell 7),有什么办法吗?

.net com

3
推荐指数
1
解决办法
2803
查看次数

标签 统计

.net ×3

c# ×2

visual-studio ×2

breakpoints ×1

com ×1

debugging ×1