Turn off Visual Studio Attach security warning when debugging IIS

roundcrisis picture roundcrisis · Sep 12, 2009 · Viewed 35.6k times · Source

When using Visual Studio 2008 or 2010, every time you attach to IIS w3wp.exe you get an Attach Security Warning,

How do you turn this of?

It would be cool to know also, how to keep it attached for linger, as this seems to time out after a while.

Btw: I Added this as a comment to the answer below, the first thing I did was try the msdn article http://msdn.microsoft.com/en-us/library/ms241736.aspx but that doesn't work.

Answer

Wiebe Tijsma picture Wiebe Tijsma · Jan 8, 2010

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

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
}