Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 4 MVC4中与Active Directory相关的AppDomainUnloadexception_Asp.net Mvc 4_Active Directory_Userprincipal - Fatal编程技术网

Asp.net mvc 4 MVC4中与Active Directory相关的AppDomainUnloadexception

Asp.net mvc 4 MVC4中与Active Directory相关的AppDomainUnloadexception,asp.net-mvc-4,active-directory,userprincipal,Asp.net Mvc 4,Active Directory,Userprincipal,我有一个ASP.NETMVC应用程序。它在域上运行,我们通过调用UserPrincipal.Current来确定用户。这在大多数情况下都非常有效。每隔一段时间(可能是5次中的1次),只有在我将我的应用发布到IIS之后,它才会抛出AppDomainUnloadexception 导致异常的特定代码行是: if (UserPrincipal.Current.SamAccountName != null && _currentUserId != UserPrincipal.C

我有一个ASP.NETMVC应用程序。它在域上运行,我们通过调用
UserPrincipal.Current
来确定用户。这在大多数情况下都非常有效。每隔一段时间(可能是5次中的1次),只有在我将我的应用发布到IIS之后,它才会抛出AppDomainUnloadexception

导致异常的特定代码行是:

if (UserPrincipal.Current.SamAccountName != null && 
    _currentUserId != UserPrincipal.Current.SamAccountName) ...
调用堆栈的其余部分是:

mscorlib.dll!System.StubHelpers.StubHelpers.GetCOMHRExceptionObject(int hr, System.IntPtr pCPCMD, object pThis) + 0xe bytes 
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.ADStoreCtx.LoadDomainInfo() + 0x358 bytes 
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.ADStoreCtx.DnsDomainName.get() + 0x5e bytes   
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.ADStoreCtx.GetAsPrincipal(object storeObject, object discriminant = {Name = "UserPrincipal" FullName = "System.DirectoryServices.AccountManagement.UserPrincipal"}) + 0x17a bytes 
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.ADStoreCtx.FindPrincipalByIdentRefHelper(System.Type principalType, string urnScheme, string urnValue, System.DateTime referenceDate, bool useSidHistory) + 0x576 bytes   
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.ADStoreCtx.FindPrincipalByIdentRef(System.Type principalType, string urnScheme, string urnValue, System.DateTime referenceDate) + 0x35 bytes  
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithTypeHelper(System.DirectoryServices.AccountManagement.PrincipalContext context, System.Type principalType, System.DirectoryServices.AccountManagement.IdentityType? identityType, string identityValue, System.DateTime refDate) + 0x9e bytes 
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithType(System.DirectoryServices.AccountManagement.PrincipalContext context, System.Type principalType, System.DirectoryServices.AccountManagement.IdentityType identityType, string identityValue) + 0x5b bytes 
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.UserPrincipal.FindByIdentity(System.DirectoryServices.AccountManagement.PrincipalContext context, System.DirectoryServices.AccountManagement.IdentityType identityType, string identityValue) + 0x1e bytes    
System.DirectoryServices.AccountManagement.dll!System.DirectoryServices.AccountManagement.UserPrincipal.Current.get() + 0xc1 bytes
经过大量的挖掘,由于异常的随机性,我得出结论,问题可能与此有关:

所以我安装了修补程序,正如预期的那样,问题消失了。那是星期二。今天早上,异常再次启动。我验证了hotifx实际上已安装。我打开模块加载消息并获得:

'w3wp.exe': Loaded 'C:\Windows\SysWOW64\activeds.dll', Cannot find or open the PDB file.
因此,我验证了.dll实际上是修补程序中的一个,它是(大小和版本匹配)

在获取此异常的同时,我在事件日志中获取此事件:

A process serving application pool 'WebSitePool' suffered a fatal communication error with the Windows Process Activation Service. The process id was '7404'. The data field contains the error number.
错误中唯一的数据是:0x8007006D,我相信这仅仅意味着有一个致命的通信错误,错误已经说过了

有趣的是,当异常对话框弹出时,它会说,“如果有此异常的处理程序,程序可能会安全地继续。”如果你的应用程序不需要UserPrincipal.Current,这是正确的,但是在此异常后再次调用它会导致异常重新出现,因此我会质疑他们的“安全继续”断言

现在,如果我重新运行应用程序,我不会有问题。除了在出版之后,我还没有在任何时候发生过这种情况。由于我们的设置和与其他项目的关系,此应用程序必须在IIS下调试,这意味着每次更改代码时我都必须发布它,这意味着我通常一整天都会看到它(周二下午和昨天除外)

我觉得奇怪的是,通过四处挖掘,似乎这个bug经常与ASP.NET MVC关联,但我不相信我见过它与WinForms或ASP.NET关联。。。我看不出这有什么关系,但也许有关系


我怀疑这是微软的错误。我无法想象在任何合法的条件下UserPrincipal.Current都会导致AppDomainUnloadedException,但我想我应该在Stackoverflow上试一试

你找到解决办法了吗?没有。在我们的情况下,问题自行解决了。但我确信这是.NET框架广告部分的一个缺陷。