I have a strange System.DirectoryServices problem that appears periodically.
The below exception is periodically thrown in the code below
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; } }
Stacktrace exception in System.Reflection.RuntimeAssembly._nLoad (AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark & stackMark, Boolean throwOnFileNotFound, BooleanEmeLiefLementLiefNementLiefNeferencePreferenceNextRepreference , StackCrawlMark & stackMark) in System.DirectoryServices.AccountManagement.UnsafeNativeMethods.IADsPathname.Retrieve (Int32 lnFormatType) in System.DirectoryServices.AccountManagement.ADStoreCtx.LoadDomainInfo () in System.DirectMentoryStoreContainmentStoreContainmentStoreContainmentStoreContainmentStoreContainmentStoreContainmentStoreContainmentMonitorContainmentMonitorInstore.ContentManager AccountManagement.ADStoreCtx.GetGroupsMemberOfAZ (Principal p) in System.DirectoryServices.AccountManagement.UserPrincipal.GetAuthorizationGroupsHelper ()
Something very strange is Exception.Message, which: Failed to load the file or assembly "MyCustomAssembly.XmlSerializers" or one of its dependencies. The system cannot find the specified file.
The funny thing is that MyCustomAssembly is not even mentioned in this assembly.
I think Exception.Message does not match Debug information, and the actual Stacktrace is more or less the correct Exception.
Any idea why this is happening?
source share