由于有个程序只能在CNC上运行,不能在PC运行,这就导致调试起来很不方便。后来才发现VS是有远程调试功能的;现在把配置过程列下来以备以后查询。

 

1. 安装remote debugger.

在PC的VS安装目录下找到msvsmon.exe ,此文件就是remote debugger.

我的VS2022 的安装位置在:

D:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\Remote Debugger\x64

D:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\Remote Debugger\x86 

根据CNC的位数,将对应的版本的整个文件夹拷贝到CNC上;

image

 

2. 目标主机上运行remote debugger

   将上一步考到CNC上的msvsmon.exe 右键“以管理员身份运行”,在打开的界面菜单“tools”--> “options”->

image

勾选“No Authentication”-> “allow any user to debug”;

TCP/IP 端口号使用默认的即可;

Max idle time 设置超时时间;设为0 则永远不会超时,一直处于等待状态;这里默认即可;

 

image

 

3. 配置VS工程。

在PC上打开项目,“项目”--》“属性”--》“configuration Properties”--> “Debugging” 

image

 

4. 开始远程调试

代码中设置断点,点击上面的“remote windows Debugger”远程调试。

CNC 上的msvsmon.exe界面上链接成功会显示连接。

 

image

 

 参考:Visual Studio Debug :远程调试(小白必读)_vs远程调试-CSDN博客

 

posted on 2026-05-28 13:07  lazybee  阅读(77)  评论(0)    收藏  举报