简体   繁体   English

如何使用C#执行vsjitdebugger.exe

[英]How to execute vsjitdebugger.exe using c#

I'd like to execute 'vsjitdebugger.exe' for some process using the code below: 我想使用以下代码为某些过程执行“ vsjitdebugger.exe”:

var myapp = Process.Start(@"path\to\myapp.exe");
Process.Start("vsjitdebugger.exe", $"-p {myapp.Id}").WaitForExit();

But failed. 但是失败了。
The exit code is '-1' without showing the window. 退出代码为“ -1”,不显示窗口。

What do I have to do in order to execute vsjitdebugger.exe? 为了执行vsjitdebugger.exe,我必须做什么?

UPATE #1 UPATE#1
I'd like to attach debugger to the specific process only instantly. 我只想立即将调试器附加到特定进程。
That's why I profer code way instead of registry way. 这就是为什么我提供代码方式而不是注册表方式的原因。

To execute as administrator: 要以管理员身份执行:

var myapp = Process.Start(@"path\to\myapp.exe");
Process.Start(new ProcessStartInfo()
{
     FileName = @"vsjitdebugger.exe",
     Arguments = "-p {myapp.Id}",
     Verb = "runas"
}).WaitForExit();

Failed as well after UAC screen. 在UAC屏幕之后也失败。

Lunching the just-in-time debugger through code will not work for you as you must run with admin privileges in order to use it. 通过代码为即时调试器提供午餐对您不起作用,因为您必须以管理员权限运行才能使用它。

What you can do, is start the debugger Automatically on your desired process. 您可以做的是在所需的过程中自动启动调试器。

I'd suggest reading more about the JIT of visual studio here as well before trying to execute process through C#. 我建议你阅读更多有关Visual Studio的JIT 这里还有之前试图通过C#来执行过程。

This is not safe at all and considered bad practice. 这一点都不安全,被认为是不好的做法。 Unless there is an urgent need I would suggest maxing out all your other possibilities first. 除非有紧急需求,否则我建议您先最大化其他所有可能性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM