gpt4 book ai didi

c# - 使用应用程序池标识会导致异常和事件日志

转载 作者:行者123 更新时间:2023-11-30 20:00:12 25 4
gpt4 key购买 nike

我最近将我的应用程序从使用 ASP.NET 模拟切换为在应用程序池中实际指定身份。这样做的原因是为了让以后更容易使用 async,以便线程作为我的服务帐户运行。

自从进行更改以来,该网站一直遇到一些问题。在我进行更改的那天,我现在看到这些事件日志显示得更频繁(以前每天 2-3 次,现在每天 8-10 次):

Windows detected your registry file is still in use by other applications or services. The file will be unloaded now. The applications or services that hold your registry file may not function properly afterwards.  

DETAIL -
3 user registry handles leaked from \Registry\User\S-1-5-21-1695807550-3099950144-3292890465-4346:
Process 3840 (\Device\HarddiskVolume2\Windows\System32\inetsrv\w3wp.exe) has opened key \REGISTRY\USER\S-1-5-21-1695807550-3099950144-3292890465-4346
Process 3840 (\Device\HarddiskVolume2\Windows\System32\inetsrv\w3wp.exe) has opened key \REGISTRY\USER\S-1-5-21-1695807550-3099950144-3292890465-4346\Control Panel\International
Process 3840 (\Device\HarddiskVolume2\Windows\System32\inetsrv\w3wp.exe) has opened key \REGISTRY\USER\S-1-5-21-1695807550-3099950144-3292890465-4346\Software\Microsoft\Windows\CurrentVersion\Explorer

在与 active directory 交谈时,我也遇到了(看似随机的)错误:

System.Runtime.InteropServices.COMException (0x80005000): Unknown error (0x80005000)
at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_AdsObject()
at System.DirectoryServices.PropertyValueCollection.PopulateList()
at System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry entry, String propertyName)
at System.DirectoryServices.PropertyCollection.get_Item(String propertyName)
at System.DirectoryServices.AccountManagement.PrincipalContext.DoLDAPDirectoryInitNoContainer()
at System.DirectoryServices.AccountManagement.PrincipalContext.DoDomainInit()
at System.DirectoryServices.AccountManagement.PrincipalContext.Initialize()
at System.DirectoryServices.AccountManagement.PrincipalContext.get_QueryCtx()
at System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithTypeHelper(PrincipalContext context, Type principalType, Nullable`1 identityType, String identityValue, DateTime refDate)
at System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithType(PrincipalContext context, Type principalType, IdentityType identityType, String identityValue)
at System.DirectoryServices.AccountManagement.UserPrincipal.FindByIdentity(PrincipalContext context, IdentityType identityType, String identityValue)

我在进行更改后看到的最后一个错误(尽管它似乎不太经常发生):

System.Runtime.InteropServices.COMException (0x800703FA): Illegal operation attempted on a registry key that has been marked for deletion.

at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_AdsObject()
at System.DirectoryServices.PropertyValueCollection.PopulateList()
at System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry entry, String propertyName)
at System.DirectoryServices.PropertyCollection.get_Item(String propertyName)
at System.DirectoryServices.AccountManagement.PrincipalContext.DoLDAPDirectoryInitNoContainer()
at System.DirectoryServices.AccountManagement.PrincipalContext.DoDomainInit()
at System.DirectoryServices.AccountManagement.PrincipalContext.Initialize()
at System.DirectoryServices.AccountManagement.PrincipalContext.get_QueryCtx()
at System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithTypeHelper(PrincipalContext context, Type principalType, Nullable`1 identityType, String identityValue, DateTime refDate)
at System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithType(PrincipalContext context, Type principalType, IdentityType identityType, String identityValue)
at System.DirectoryServices.AccountManagement.UserPrincipal.FindByIdentity(PrincipalContext context, IdentityType identityType, String identityValue)

一旦我重置了应用程序池,问题就消失了。不幸的是,它似乎在一两天后又回来了。

有人知道这里发生了什么吗?我可以重新使用模拟,因为在我将应用程序池身份切换为特定用户之前,这种情况从未发生过。我的 Google-fu 今天没有给我任何答案。

最佳答案

我无法找到问题的根本原因。但是,如果底层代码依赖于属于该身份的资源,那么对多个应用程序池使用相同的身份似乎会导致一些问题。

将应用程序池设置 Load User Profile 更改为 True 解决了该问题并且事件日志条目停止出现。

关于c# - 使用应用程序池标识会导致异常和事件日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21941216/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com