使用 Visual Studio 2008 或 2010 时,每次附加到 IIS w3wp.exe 时,都会收到附加安全警告,

你如何扭转这一局面?

如果知道如何保持它的连接以逗留,那就很酷了,因为这似乎会在一段时间后超时。

顺便提一句:我将此作为评论添加到下面的答案中,我做的第一件事就是尝试 msdn 文章 http://msdn.microsoft.com/en-us/library/ms241736.aspx 但这行不通。

有帮助吗?

解决方案

还可以在 Tzury 提到的文章中找到,但总结一下该线程中的答案:

确保更改注册表项时 Visual Studio 未运行,否则退出时它将被旧值覆盖

将以下注册表项更改(或创建)为 1:

视觉工作室2008 HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\Debugger\DisableAttachSecurityWarning

视觉工作室2010 HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\Debugger\DisableAttachSecurityWarning

视觉工作室2012 HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\Debugger\DisableAttachSecurityWarning

视觉工作室2013 HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\Debugger\DisableAttachSecurityWarning

视觉工作室 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.

更新: 如果您不想打开注册表,请保存此 要旨 作为 *.reg 文件并运行它(导入低于 VS2017 的所有 VS 版本的密钥)。

视觉工作室 2017

配置保存在私有注册表位置,请参阅此答案: https://stackoverflow.com/a/41122603/67910

为了 对比2017年, ,保存这个 要旨 作为 *.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
}

其他提示

注册表设置确实有效;但是,您必须确保在32位注册表沙箱中为VS2005 / 2008设置它,方法是使用%windir%\ SysWOW64 \ 中的32位regedit.exe或将其添加到<代码> HKLM \ SOFTWARE \ Wow6432Node \ ... 。我创建了一个.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

只需将版本更改为2005年的10.0,2010年的10.0等,

注意:Windows 7上的regedit似乎希望将.reg文件保存为UTF16-LE,因此如果将其保存为.reg文件,请注意您需要这样做。

我能够在Windows 7上运行。我首先更改了VS2008仍然打开的注册表值。然后我关闭它并刷新注册表编辑器并注意到该值已重置为0.然后我将其更改回1并启动VS2008。它现在工作正常。我试图关闭VS2008并将其打开,注册表值保持为1.感谢您的帮助

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

  • 确保没有 Visual Studio 实例正在运行(使用任务管理器检查 devenv.exe)
  • 添加双字 禁用附加安全警告 注册表值 HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\X.X\Debugger 并将值设置为 1. 。对于 Visual Studio 2008,将 X.X 替换为 9.0, 2010 年使用 10.0

我努力让这个工作的原因是我正在尝试使用 HKEY_LOCAL_MACHINE 而不是 HKEY_CURRENT_USER。我不得不求助于使用 过程监控器 并对 devenv 进行一些过滤以识别我的错误。我怀疑 HKLM 值只有在首次打开 Visual Studio 之前设置它才会产生任何影响。

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

使用 Wow6432节点 据我所知,注册表似乎是不必要的。以下 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

您可以将iis AppPool标识更改为您的实际Windows用户(如果它是本地计算机)。

您的答案可在 http://msdn.microsoft.com/上找到。 EN-US /库/ ms241736.aspx

  

如果您正在调试合法的   导致此警告的方案   出现,并希望压制它,那里   是一个允许您的注册表设置   去做这个。记得重新启用   完成后的警告   场景。

这不是问题的直接答案,但它绕过了安全消息,并且还提供了一种更快的方法来附加到先前附加的进程:

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

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

所以,在x64 / Win7上使用Visual Studio 2010对我来说唯一有用的就是更新两个节点,包括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

Visual Studio扩展可用于VS2015和VS2017:“附加到所有东西&QUOT;

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

基于SliverNinja和Martin Hollingsworth现有答案的 powershell 变体。已在 win7 / x64 环境中使用 Visual Studio 2015 对此进行了测试。该脚本将要求您关闭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!"
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top