gpt4 book ai didi

.net - System.DirectoryServices 中的间歇性异常

转载 作者:行者123 更新时间:2023-12-02 15:08:50 24 4
gpt4 key购买 nike

我有一个奇怪的 System.DirectoryServices 问题,它间歇性地弹出。

在下面的代码中定期抛出下面的异常

    private PrincipalSearchResult<Principal> GetAuthorizationGroups(UserPrincipal userPrincipal, int tries)
{
try
{
//Exception is thrown on this line below
return userPrincipal.GetAuthorizationGroups();
}
catch (AppDomainUnloadedException ex)
{
if (tries > 5)
{
throw;
}
tries += 1;
Thread.Sleep(5000);
return GetAuthorizationGroups(userPrincipal, tries);
}
catch (Exception ex)
{
throw;
}
}

System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName、String codeBase、Evidence assemblySecurity、RuntimeAssembly locationHint、StackCrawlMark& stackMark、 bool 值 throwOnFileNotFound、 bool 值 forIntrospection、 bool 值抑制SecurityChecks)处的异常堆栈跟踪 System.Reflection.RuntimeAssembly.LoadWithPartialNameInternal(AssemblyName an,证据 securityEvidence、StackCrawlMark& stackMark) 在 System.DirectoryServices.AccountManagement.UnsafeNativeMethods.IADsPathname.Retrieve(Int32 lnFormatType) 在 System.DirectoryServices.AccountManagement.ADStoreCtx.LoadDomainInfo() 在 System.DirectoryServices.AccountManagement.ADStoreCtx.get_DnsDomainName() 在 System.DirectoryServices System.DirectoryServices.AccountManagement.UserPrincipal.GetAuthorizationGroupsHelper() 处的 .AccountManagement.ADStoreCtx.GetGroupsMemberOfAZ(Principal p)

还有一点很奇怪的是 Exception.Message,它是:无法加载文件或程序集“MyCustomAssembly.XmlSerializers”或其依赖项之一。系统找不到指定的文件

有趣的是,这个程序集中甚至没有引用 MyCustomAssembly。

我认为 Exception.Message 与调试信息不​​匹配,实际的 Stacktrace 或多或少是正确的异常。

知道为什么会发生这种情况吗?

最佳答案

我知道你很久以前就问过这个问题,但我自己也遇到了这个问题,并通过我的构建配置管理器并确保所有项目都针对相同的 CPU 来解决它 - 我有 2 个构建为“任何 CPU”以及面向 x86 构建的 Windows 窗体测试应用程序。我将其更改为 Any CPU,问题就消失了。

here得到提示

关于.net - System.DirectoryServices 中的间歇性异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9410300/

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