I have implemented a custom SPClaimProvider that is doing claims augmentation in the FillClaimsForEntity method. I have packaged this as a SharePoint feature and deploy it in a WSP.
I am trying to uninstall the existing version and add a new version of the same assembly. After I uninstall the existing version, the token service is still looking for the old assembly.
At first, the problem was that the feature was missing. I then used the Feature Admin Tool to find the faulty feature and remove it.
Faulty Feature found! Id: '12345678-1234-1234-123456789012 Found in Scope:Web, http://vm-sps-5e. Should it be removed from the farm?
Farm - Removing Feature '12345678-1234-1234-123456789012, Scope: Web' from the Farm.
WebApp - Removing Feature '12345678-1234-1234-123456789012' from Web Application: 'SharePoint - vm-sps-5e'.
SiteColl - 1 Web Scoped Features removed in the SiteCollection http://vm-sps-5e. 1 sites/subsites were scanned.
This removed the feature, but a reference to the old assembly still exists somewhere.
Edit: A more detailed stack trace
SPSecurityTokenService.Issue() failed: System.IO.FileNotFoundException: Could not load file or assembly 'ClaimsAssembly, Version=2.7.0.10, Culture=neutral, PublicKeyToken=0123456789012345' or one of its dependencies. The system cannot find the file specified. File name: 'ClaimsAssembly, Version=2.7.0.10, Culture=neutral, PublicKeyToken=0123456789012345' at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.Load(String assemblyString) at Microsoft.SharePoint.Administration.Claims.SPClaimProviderDefinition.GetClaimProviderType(String assemblyName, String typeName) at Microsoft.SharePoint.Administration.Claims.SPClaimProviderDefinition.get_ClaimProviderType() at Microsoft.SharePoint.Administration.Claims.SPClaimProviderDefinition.CreateClaimProvider() at Microsoft.SharePoint.Administration.Claims.SPClaimProviderManager.get_EnabledClaimProvidersByName() at Microsoft.SharePoint.Administration.Claims.SPClaimProviderManager.GetEnabledClaimProviders(SPClaimProviderOperationOptions mode) at Microsoft.SharePoint.Administration.Claims.SPClaimProviderManager.GetClaimProviders(SPWebApplication webApplication, Nullable 1 zone, SPClaimProviderOperationOptions mode) at Microsoft.SharePoint.Administration.Claims.SPClaimProviderManager.GetClaimProvidersForContext(Uri context, SPClaimProviderOperationOptions mode, IEnumerable`1 providerNames) at Microsoft.SharePoint.Administration.Claims.SPClaimProviderOperations.ClaimsForEntity(Uri context, SPClaimProviderOperationOptions mode, String[] providerNames, SPClaim entity) at Microsoft.SharePoint.IdentityModel.SPSecurityTokenService.AugmentClaimsIdentity(IClaimsIdentity identity, SPClaim identityClaim, RequestSecurityToken request) at Microsoft.SharePoint.IdentityModel.SPSecurityTokenService.GetOutputClaimsIdentity(IClaimsPrincipal principal, RequestSecurityToken request, Scope scope) at Microsoft.IdentityModel.SecurityTokenService.SecurityTokenService.Issue(IClaimsPrincipal principal, RequestSecurityToken request) at Microsoft.SharePoint.IdentityModel.SPSecurityTokenService.Issue(IClaimsPrincipal principal, RequestSecurityToken request) WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
Edit:
The command Get-SPClaimProvider displayed that the custom claim provider was configured in the list of all claims providers - finally... found it.
I tried to remove it using: Remove-SPClaimProvider -Identity ClaimsAssembly.CustomSPClaimProvider
Could not load file or assembly 'ClaimsAssembly, Version=2.7.0.10, Culture=neutral, PublicKeyToken=0123456789012345' or one of its dependencies. The system cannot find the file specified.
Above all, once there is an error in the token service itself, it is very hard for SharePoint to do anything at all.
