可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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.
回答1:
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.
- Make sure Visual Studio is not running, and open the Registry Editor.
- 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
}
回答2:
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.
回答3:
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
回答4:
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
回答5:
You can change the iis AppPool identity to your actual windows user, if it is a local machine.
回答6:
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.
回答7:
This is not a direct answer to the question, but it circumvents the security message and also provides a faster way to attach to a previously attached process:
- install Reattach extension
- attach using Reattach and the message is bypassed
- re-attaching (Ctrl-R + Ctrl-[1-5]) to a previous process has the same benefit
回答8:
Powershell variant...replace $vsversion
with the version you want to apply it to.
Note: Save your work before running this. All running VS instances will be stopped. If you don't end open VS instances - the value will not be retained.
$vsversion = "12.0" # VS 2013 (optionally 11, 10, 9, etc.)
kill -name devenv # end any existing VS instances (required for persisting config change)
Get-ItemProperty -Path "HKCU:\Software\Microsoft\VisualStudio\$vsversion\Debugger" -Name DisableAttachSecurityWarning -ErrorAction SilentlyContinue # query value (ignore if not exists)
Set-ItemProperty -Path "HKCU:\Software\Microsoft\VisualStudio\$vsversion\Debugger" -Name DisableAttachSecurityWarning -Value 1 # assign value
回答9:
so, the only thing that would work for me with Visual Studio 2010 on x64/Win7 is to update both nodes, including the Wow6432Node.
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\Debugger]
"DisableAttachSecurityWarning"=dword:00000001
[HKEY_CURRENT_USER\Software\Wow6432Node\Microsoft\VisualStudio\10.0\Debugger]
"DisableAttachSecurityWarning"=dword:00000001
回答10:
A Visual Studio extension is available for VS2015 and VS2017: "Attach To All The Things":
You can bind "Attach To IIS" to whatever key chord you like using the usual process.
回答11:
A powershell variation based on existing answers from SliverNinja and Martin Hollingsworth. This has been tested with Visual Studio 2015 on a win7/x64 environment. The script will ask you to close Visual Studio if it's running (won't try to kill it).
$vsversion = "14.0" # VS 2015 (optionally 12, 11, 10, 9, etc...)
$disable = 1 # set to 0 to enable the warning message
# not using Get-Process here because powershell instance can be 64 bit and devenv is 32 bit
if (!(get-wmiobject win32_process -filter "name='devenv.exe'")) {
# Create or (force) update the property
New-ItemProperty -Path "HKCU:\Software\Microsoft\VisualStudio\$vsversion\Debugger" -Name DisableAttachSecurityWarning -Value $disable -PropertyType 'DWORD' -Force
Write-Host Done!
}
else {
Write-Error "Please close Visual Studio first!"
}