到目前为止,我知道问题与我的Windows帐户无关。在另一台设备上,切换分支只需要几秒钟,而不是一分钟。我们注意到在 慢 电脑上有更多的网络流量。
当我以安全模式运行Visual Studio时,
devenv.exe /SafeMode
我立刻在“团队资源管理器”中看到以下错误:
System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(Int32 hr, Int32[] expectedHRFailure)
at Microsoft.TeamFoundation.Git.Provider.ServiceProviderExtensionMethods.EnsurePackageLoaded(IServiceProvider serviceProvider, Guid packageGuid)
at Microsoft.TeamFoundation.Git.Provider.ServiceProviderExtensionMethods.EnsureSccAndTfPackagesLoaded(IServiceProvider serviceProvider)
at Microsoft.TeamFoundation.Git.Provider.Repositories.GitTeamProjectExtendedInfoProvider.set_ServiceProvider(IServiceProvider value)
at Microsoft.VisualStudio.TeamFoundation.TeamExplorer.ConnectPage.ConnectPageVS.Initialize(Object sender, PageInitializeEventArgs e)
at Microsoft.TeamFoundation.Controls.WPF.TeamExplorer.Framework.TeamExplorerPageHost.Initialize(TeamExplorerPageContext context)
建议如msdn所示,我尝试的第一件事是:
devenv.exe /updateConfiguration
但这并没有解决问题。然后我运行了:
devenv.exe /setup
它会显示以下错误信息:
无法完成操作。所请求的操作需要提升权限。
devenv.exe /SafeMode /log D:\temp
我在日志中看到的错误是:
Error loading UI library for package WebEditorPackage. HrLoadNativeUILibrary failed with 0x800a006f.
Error loading UI library for package Microsoft.VsSDK.ExtensibilityProjectFlavor.ExtensibilityProjectFlavorPackage. HrLoadNativeUILibrary failed with 0x800a006f.
Failed to find CTMENU resource '#1000' in loaded UI library.
我以管理员身份运行了Visual Studio。问题仍然存在,但是当之后作为用户在安全模式下运行时,日志中不再有任何错误行。
常规启动时,我看到一个错误和许多警告:
ERROR Encountered an ArgumentException when trying to look up the key binding information for ({ef254ccf-cee3-43e9-a22c-3ae3ab08e7fe},256) in the scope {5efc7975-14bc-11cf-9b2b-00aa00573819}.
Unexpected system error mode before loading package [Microsoft.VisualStudio.Services.Promotions.PromotionsPackage]
Unexpected system error mode before loading package [InstallerPackage]
About to block on async service creation because the service was requested via GetService. This has the potential to deadlock. Async initializing services should be retrieved via GetServiceAsync.
PkgDef syntax or I/O error at line 1: Section header: additional characters after closing bracket
[$RootKey$\Setup\[ProductName]] 80004005 - E_FAIL
PkgDef syntax or I/O error at line 3: Section header: additional characters after closing bracket
"SrcPath"="[SourceDir]" 80004005 - E_FAIL
Could not process PkgDef file
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\Extensions\Community\Detection_Keys_Reg.pkgdef
一个Visual Studio的修复也没有解决问题。我正在使用Visual Studio 15.6.5。
我运行了sfc来检查Windows系统文件。
sfc /scannow
Beginning system scan. This process will take some time.
Beginning verification phase of system scan.
Verification 100% complete.
Windows Resource Protection found corrupt files but was unable to fix some
of them. Details are included in the CBS.Log windir\Logs\CBS\CBS.log. For
example C:\Windows\Logs\CBS\CBS.log. Note that logging is currently not
supported in offline servicing scenarios.
这样的错误有很多:
CSI 000010f2 [DIRSD OWNER WARNING] Directory [l:48 ml:49]'\??\C:\Program Files\Windows Identity Foundation' is not owned but specifies SDDL in component c2wtsres, arch amd64, nonSxS, pkt {l:8 b:31bf3856ad364e35}
CSI 000010f3 [DIRSD OWNER WARNING] Directory [l:53 ml:54]'\??\C:\Program Files\Windows Identity Foundation\v3.5' is not owned but specifies SDDL in component c2wtsres, arch amd64, nonSxS, pkt {l:8 b:31bf3856ad364e35}
CSI 000010f4 Error - Overlap: Duplicate ownership for directory \??\C:\Program Files\Windows Identity Foundation in component c2wtsres, version 10.0.14393.0, arch amd64, nonSxS, pkt {l:8 b:31bf3856ad364e35}
CSI 000010f5 Error - Overlap: Duplicate ownership for directory \??\C:\Program Files\Windows Identity Foundation\v3.5 in component c2wtsres, version 10.0.14393.0, arch amd64, nonSxS, pkt {l:8 b:31bf3856ad364e35}
Process Monitor日志显示在Git和VS之间切换。磁盘操作本身很快,但是在git.exe FileCloses C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\bin\git.exe
后,它需要几乎一秒钟才能关闭C:\Windows
。并且在来自git.exe的QueryNameInformationFile事件之后,它会在C:\Windows\System32\conhost.exe
上执行CloseFile操作,大约一秒钟后。
当没有特殊情况发生时,我进行了Wireshark捕获。我看到我的PC和webdefence.cluster-x.websense.net之间有大量流量,这是公司代理服务器。流量比我的同事多得多,他们没有看到错误。
使用有线、无线或VPN连接在家中时,问题仍然存在。我怀疑这是NTFS权限的问题?
我尝试运行SFCFix,但没有成功。
SFCFix Has Crashed
Something has gone horribly wrong and SFCFix has crashed. Would you like SFCFix
to submit a crash report to the developer so that this problem can be fixed?
Type "y" for yes or "n" for no and press enter to continue:
我还尝试了其他工具,但都没有成功。
D:\Tools>DISM /Online /Cleanup-Image /StartComponentCleanup /ResetBase
Deployment Image Servicing and Management tool
Version: 10.0.14393.0
Image Version: 10.0.14393.0
[=========== 20.0% ]
The operation completed successfully.
D:\Tools>Dism /Online /Cleanup-Image /RestoreHealth
Deployment Image Servicing and Management tool
Version: 10.0.14393.0
Image Version: 10.0.14393.0
[==========================100.0%==========================]
Error: 0x800f081f
The source files could not be found.
Use the "Source" option to specify the location of the files that are required to restore the feature. For more information on specifying a source location, see http://go.microsoft.com/fwlink/?LinkId=243077.
The DISM log file can be found at C:\WINDOWS\Logs\DISM\dism.log
Tweaking.com - Windows Repair 2018也无法修复文件权限。