Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turn off Visual Studio Attach security warning when debugging IIS

Also found in the article mentioned by Tzury, but to sum up the answers in this thread:

Make sure Visual Studio is not running when changing the registry key or it will be overwritten on exit with the old value

Visual Studio 2019: Follow these instructions, then reboot.

For older versions of Visual Studio:

Change (or create) the following registry key to 1:

Visual Studio 2008 HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\Debugger\DisableAttachSecurityWarning

Visual Studio 2010 HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\Debugger\DisableAttachSecurityWarning

Visual Studio 2012 HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\Debugger\DisableAttachSecurityWarning

Visual Studio 2013 HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\Debugger\DisableAttachSecurityWarning

Visual Studio 2015 HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\Debugger\DisableAttachSecurityWarning

For VS2015, you might need to create the Registry Key referenced above.

  1. Make sure Visual Studio is not running, and open the Registry Editor.
  2. Navigate to HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\Debugger, right-click and create a new DWORD:
  • Name: DisableAttachSecurityWarning
  • Value: 1.

Update: If you don't want to open up regedit, save this gist as a *.reg file and run it (imports the keys for all VS versions lower than VS2017).

Visual Studio 2017

The configuration is saved in a private registry location, see this answer: https://stackoverflow.com/a/41122603/67910

For VS 2017, save this gist as a *.ps1 file and run it as admin, or copy and paste the following code in a ps1 file:

#IMPORTANT: Must be run as admin

dir $env:LOCALAPPDATA\Microsoft\VisualStudio\15.* | % {
    #https://stackoverflow.com/a/41122603
    New-PSDrive HKU Registry HKEY_USERS

    reg load 'HKU\VS2017PrivateRegistry\' $_\privateregistry.bin

    $BasePath='HKU:\VS2017PrivateRegistry\Software\Microsoft\VisualStudio'

    $keysResult=dir $BasePath
    $keysResult | ? {$_.Name -match '\\\d+\.\d+_[^_]+$'} | % {
        $keyName = $_.Name -replace 'HKEY_USERS','HKU:'
        New-ItemProperty -Path $keyName\Debugger -Name DisableAttachSecurityWarning -Value 1
    }
    $keysResult.Handle.Close()    

    [gc]::collect()

    reg unload 'HKU\VS2017PrivateRegistry'

    Remove-PSDrive HKU
}

The registry setting does work; however, you have to make sure you set it in the 32-bit registry sandbox for VS2005/2008 by either using the 32-bit regedit.exe in %windir%\SysWOW64\ or adding it under HKLM\Software\Wow6432Node\.... I created a .reg script that simply adds it to both:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\Debugger]
"DisableAttachSecurityWarning"=dword:00000001

[HKEY_CURRENT_USER\Software\Wow6432Node\Microsoft\VisualStudio\9.0\Debugger]
"DisableAttachSecurityWarning"=dword:00000001

Just change the version to 8.0 for 2005, 10.0 for 2010, etc.

NOTE: regedit on Windows 7 seems to want .reg files saved as UTF16-LE, so if you save it to a .reg file, be aware you need to do that.


I was able to make it Work on Windows 7. I have first changed the registry value with VS2008 still opened. I then closed it and refreshed the registry editor and noticed that the value was reset to 0. I then changed it back to 1 and started VS2008. It now works fine. I have tried to close VS2008 and open it back and the registry value stays 1. Thanks for your help


The other answers in this post contain the right information but I had problems getting it to work so this is an attempt at make the answer very explicit. These instructions worked for Visual Studio 2010 running on Windows 7 Ultimate 64-Bit.

  • Ensure that no instances of Visual Studio are running (Use task manager to check for devenv.exe)
  • Add the DWORD DisableAttachSecurityWarning registry value to HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\X.X\Debugger and set the value to be 1. For Visual Studio 2008 replace X.X with 9.0, for 2010 use 10.0

The reason why I struggled to get this working was that I was trying this using HKEY_LOCAL_MACHINE instead of HKEY_CURRENT_USER. I had to resort to using Process Monitor and a bit of filtering on devenv to identify my mistake. I suspect the HKLM value only has any affect if it gets set before you open Visual Studio for the first time.

Any open instances of Visual Studio will overwrite your changes when they are closed and only new instances would pick up the setting in any case.

The use of the Wow6432Node registry seems to be unnecessary as far as I can tell. The following Powershell commands will apply the steps for Visual Studio 2010.

Get-Process -Name devenv* | ForEach-Object { Stop-Process $_.Id }
New-ItemProperty -Path 'HKCU:\Software\Microsoft\VisualStudio\10.0\Debugger' -Name 'DisableAttachSecurityWarning' -Value 1 -PropertyType 'DWORD' -Force

You can change the iis AppPool identity to your actual windows user, if it is a local machine.


your answer is available at http://msdn.microsoft.com/en-us/library/ms241736.aspx

If you are debugging a legitimate scenario that causes this warning to appear, and want to suppress it, there is a registry setting that allows you to do this. Remember to re-enable the warning after you are done with the scenario.