C # client program Visual Studio remote debugging

One, source of demand

During the development process, different versions of systems such as Win7, Win8, Win10 may be used for compatibility Debugging, sometimes it is optimized for special graphics cards, wireless network cards and other hardware devices. There is a better solution, that is, using the remote debugging function of Visual Studio, you can directly use the test machine as the debugging target and directly track With breakpoints and exceptions, you can quickly find the wrong place just like debugging on the local machine. , Without the need to install the VS environment on the test machine.

>The remote debugging of traditional desktop client is more troublesome compared to UWP, ASP and other projects, because it is a non-deployable application, the principle is to copy the compiled file to The remote computer is connected to the VS through the network. This article mainly describes the remote debugging of WPF and WinForm applications. -debugger”>①Install Remote Debugger

  • Right-click Visual Studio->Open the file location->Find the Remote Debugger folder in the current directory->Copy and paste to your remote computer , Run the program msvsmon.exe of the desired platform in the remote computer
    share picture

    < /li>

  • Run msvsmon.exe and configure secure login connection information
    Share pictures

②VS debugging remote configuration

  • Open the project properties of Visual Studio, in the debug column Check Use remote computer, enter the remote computer name and port number shown in the above picture
    Share a picture

③Remote debugging directory configuration

  • Create a new Debug directory in the remote computer, and require The Debug path in the machine where VS is installed is exactly the same
    share picture
    The picture above is a remote machine
    Share a picture
    The picture above is the debugging machine

  • Right-click the shared Debug folder and select Properties, and set the share to EveryOne.
    Share pictures

  • Copy this machine to the latest Compile the Debug folder to the Debug directory of the remote machine

    Stupid method: After successful compilation-copy-paste into the remote computer

  • Cool method: in the generation event of VS, set the post-generation event command line (as shown below)

    rem the XXX here, please do it yourself Replace with the directory xcopy $(SolutionDir)\Bin\Debug \\192.168.XX.XX\xxx\Bin\Debug\ /E /Q /Y

    Share Picture

    ④remote operation

    • click When VS is running, you can see that new files are generated in the remote directory of the remote computer. After the copy is completed, a prompt box will pop up, asking you to enter the username and password of the remote computer for verification
    • After a while, the software interface appears on the screen of the remote computer

      Attention

      < blockquote>

      ①Ensure that the remote computer and the development machine are in the same LAN ②Ensure the consistency of the Visual Studio version, such as the computer installed 2015, 2017, copy the Romote Debugger version and the actual development of the VS version requires the same ③Shared folder The access permission of EveryOne is guaranteed to be readable and writable by EveryOne

Leave a Comment

Your email address will not be published.