Azure App Service, Azure Cloud, Cloud Computing, Visual Studio

Solved: The Visual Studio 2017 Remote Debugger (MSVSMON.EXE) does not appear to be running


Errors:

The Visual Studio 2017 Remote Debugger (MSVSMON.EXE) does not appear to be running on the remote computer. This may be because a firewall is preventing communication to the remote computer

Specific method is not supported

Full Detail:

System.Runtime.InteropServices.COMException (0x89710023): Unable to connect to the Microsoft Visual Studio Remote Debugger named ‘scientistzwebapp.azurewebsites.net’. The Visual Studio 2017 Remote Debugger (MSVSMON.EXE) does not appear to be running on the remote computer. This may be because a firewall is preventing communication to the remote computer. Please see Help for assistance on configuring remote debugging.

at Microsoft.VisualStudio.Debugger.Interop.Internal.IDebuggerInternal120.ConnectToServer(String szServerName, VsDebugRemoteConnectOptions[] pConnectOptions, CONNECT_REASON ConnectReason, Int32 fIncrementUsageCount, IDebugCoreServer3& ppServer)

at Microsoft.VisualStudio.Web.Azure.MicrosoftWeb.Operations.RemoteDiagnosticsSessionBase.ConnectToServer(String site, String user, String password)

When it Happen:

If you are using Azure App Service for your application development or deployment, there are some time when you need to debug the solution, Azure provide you the feature of remote debugging. All you need to do is to Attach Debugger and Visual Studio will take care the rest for you.

Figure 1 Remote Debugging on Azure App Service

Sometimes you are not so lucky, and get the error like below:

Figure 2 The Visual Studio 2017 Remote Debugger (MSVSMON.EXE) does not appear to be running on the remote computer. This may be because a firewall is preventing communication to the remote computer

Figure 3 Specific method is not supported.

Solutions:

  1. First, you need to check if you have appropriate permissions on the Web App to do the debugging.
  2. Manually enable the debugging on Web App and try again for debugging.

Figure 4 enable Debugging on the App Service

  1. Make sure that you have published the files in debug mode.

Figure 5 Publish web app in debug mode

  1. Make sure that you are debugging in the right CPU configuration for platform is either x86 or x64, check both on Azure and Visual studio and Match the configuration.

Figure 6 Platform setting

Project | Properties | Build | Platform target

Figure 7 Visual Studio debug Platform target

  1. If you are still getting the issue, this mean there is some firewall or system setting, which is blocking your connection to the debugging service. In order to make sure, let us use Microsoft tool TCPView. When you run this tool and try to remote debug, you will see that devenv.exe (visual studio process name) is trying to connect on port 4022 to Azure IP Address but could not send any packets. This is our problem, all we need to do is to enable this port in our firewall as outgoing and debugging will work just fine.

Figure 8 TCPview to get the Process port communication

Different versions of visual studio have different ports and if you debugging in x64 mode VS2017 will use 4022 and if you are debugging in x86 then VS2017 will use 4023.

Please find below table to find out appropriate port to open in firewall.

https://docs.microsoft.com/en-us/visualstudio/debugger/remote-debugger-port-assignments

Version X64 X86
Visual Studio 2017 4022 4023
Visual Studio 2015 4020 4021
Visual Studio 2013 4018 4019
Visual Studio 2012 4016 4020

In addition to this, we need to open

Version Port
Remote Debugger Discovery 3702

More information on windows firewall configuration https://docs.microsoft.com/en-us/visualstudio/debugger/configure-the-windows-firewall-for-remote-debugging

If you are looking for more resources check below link:

https://docs.microsoft.com/en-us/azure/app-service/web-sites-dotnet-troubleshoot-visual-studio