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 2022: Follow these instructions, then reboot.
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
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)