I am trying to launch VS debugger using the code below.
When I call debugger.LaunchDebugTargets, it throws the following exception:
"Unable to attach. Process 'C:\\vlh\\Test\\CPP\\Hello\\VS2017\\Debug\\Hello.exe' is not running on 'PPLUS-DEV-VLH-1'.\n\nRefresh the process list before attempting another attach."
HResult 0x89710080
What is wrong here?
private void ButtonDebug_Click(object sender, RoutedEventArgs e)
{
ThreadHelper.ThrowIfNotOnUIThread();
try
{
var debugger = Package.GetGlobalService(typeof(IVsDebugger)) as IVsDebugger4;
VsDebugTargetInfo4[] targets = new VsDebugTargetInfo4[1];
projectInfo.Initialize();
targets[0].bstrExe = projectInfo.Command??"";
targets[0].bstrArg = projectInfo.Args??"";
VsDebugTargetProcessInfo[] processInfo = new VsDebugTargetProcessInfo[targets.Length];
debugger.LaunchDebugTargets4(1, targets, processInfo);
}
catch(Exception ex)
{
LogMessage(ex.Message);
}
}