2009-09-12 83 views
152

当使用Visual Studio 2008或2010,每次你连接到IIS w3wp.exe的时候你会得到一个附加安全警告,关闭的Visual Studio调试时,请将安全警告IIS

你怎么把这个的?

这将是很酷很酷的知道,如何保持它的逗留,因为这似乎超时一段时间后。

btw:我在下面的答案中添加了这个注释,我做的第一件事就是尝试msdn文章http://msdn.microsoft.com/en-us/library/ms241736.aspx但这不起作用。

+0

这工作到最近,在VS2015 - 我肯定有所有VS实例关闭,并设置了密钥,但警告开始再次弹出。 – fastmultiplication 2016-03-16 21:56:49

回答

215

由Tzury提到的文章中还发现,但在这个线程总结的答案:

做出更改注册表项或将退出与被覆盖时,确保Visual Studio是没有运行旧值

更改(或创建)以下注册表项,以:

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

对于VS2015,您可能需要创建上面引用的注册表项。

  1. 确保Visual Studio没有运行,并打开注册表编辑器。
  2. 导航到 HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\Debugger,单击鼠标右键,创建一个新的DWORD
    • 名称:DisableAttachSecurityWarning
    • 值:1

更新:如果你不想打开注册表编辑器,保存该gist为* .reg文件并运行它(进口键的所有VS版本比VS2017更低)。

的Visual Studio 2017年

配置保存在一个私人的注册表位置,看到这样的回答:https://stackoverflow.com/a/41122603/67910

对于VS 2017年,这gist保存为*名为.ps1文件,并运行作为管理员,或将以下代码复制并粘贴到ps1文件中:

#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 
} 
+4

这似乎也在Visual Studio 2010工作。 – Chris 2011-06-07 15:08:18

+10

对于VS2012的关键是HKEY_CURRENT_USER \ Software \ Microsoft \ VisualStudio \ 11.0 \ Debugger \ DisableAttachSecurityWarning – maddoxej 2012-10-31 17:17:37

+0

没有为我工作。这些已经设定好了。还是这样。 – Justin 2013-03-15 02:46:24

4

你的回答,请http://msdn.microsoft.com/en-us/library/ms241736.aspx

如果您正在调试一个合法 场景 出现导致该警告,并希望抑制它,有 是一个注册表设置,允许你 做这个。请记住,在完成 方案后,请重新启用 警告。

+0

应该说我试过,但没有工作 – roundcrisis 2009-09-12 15:19:20

8

我能够使其在窗口上工作s 7.我第一次改变了注册表值,VS2008仍然打开。然后我关闭它并刷新注册表编辑器,并注意到该值被重置为0.然后我将它重新更改为1,并开始VS2008。现在它工作正常。我试图关闭VS2008 ans打开它,注册表值保持为1.感谢您的帮助

13

注册表设置确实有效;但是,您必须确保通过使用%windir%\SysWOW64\中的32位regedit.exe或将其添加到HKLM\Software\Wow6432Node\...之下来确保将其设置在VS2005/2008的32位注册表沙箱中。我创建一个.reg脚本,只需将其添加到这两个:

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 

只要改变版本8.0在2005年,10.0,为2010年等

注:在Windows 7注册表编辑器似乎想的.reg文件保存为UTF16-LE,所以如果你将它保存为.reg文件,请注意你需要这样做。

6

在这篇文章中的其他答案包含正确的信息,但我有问题得到它的工作,所以这是一个尝试使答案非常明确。这些说明适用于在Windows 7 Ultimate 64位上运行的Visual Studio 2010。

  • 确保Visual Studio的任何实例正在运行(使用任务管理器来检查devenv.exe的
  • 的DWORD DisableAttachSecurityWarning注册表值添加HKEY_CURRENT_USER \ SOFTWARE \微软\ VisualStudio的\ XX \调试器并将该值设置为。对于Visual Studio 2008 9.0更换x.x中,于2010年使用10.0

我之所以努力得到这个工作是我试图用这个HKEY_LOCAL_MACHINE代替HKEY_CURRENT_USER。我不得不求助于使用Process Monitor和devenv上的一些过滤来识别我的错误。我怀疑HKLM值只有在您第一次打开Visual Studio之前设置才会有任何影响。

Visual Studio的任何打开实例在关闭时都会覆盖您的更改,并且只有新实例才会在任何情况下提取设置。

据我所知,使用Wow6432Node注册表似乎是没有必要的。下面的PowerShell命令将应用步骤,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 
2

所以,只有将我与Visual Studio 2010的工作在x64的东西/ Win7的是更新两个节点,包括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 
+3

零评论的投票。应该受到限制。 – 2014-12-15 02:37:31

5

如果是本地计算机,则可以将iis AppPool身份更改为实际的Windows用户。

+0

我最近被这个“功能”咬了一口,当你的答案让我意识到这是因为我刚从一个实际的用户账户切换到apppoolidentity。 – drzaus 2015-05-04 14:10:00

3

Powershell变体...将$vsversion替换为您要应用它的版本。

注意:保存您的工作之前运行此。所有正在运行的VS实例都将停止。如果你没有打开VS实例 - 值将不会被保留。

$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 
0

基于从SliverNinja和马丁·霍林斯沃思现有应答PowerShell的变化。这已通过Visual Studio 2015win7/x64环境中进行了测试。该脚本会要求您关闭Visual Studio(如果它正在运行)(不会试图杀死它)。

$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!" 
} 
4

这不是直接回答这个问题,但它绕开安全信息,并提供附加到一个以前附加的进程更快的方法:

  • 安装Reattach extension
  • 连接使用重新附加并且消息被绕过
  • 重新附加(Ctrl-R + Ctrl- [1-5])到先前的过程具有相同的益处
1

一个Visual Studio扩展可用于VS2015和VS2017:"Attach To All The Things"

enter image description here

可以绑定“附加到IIS”到任何键弦你喜欢使用通常的过程。