IdentityServer / IdentityServer4

OpenID Connect and OAuth 2.0 Framework for ASP.NET Core
https://identityserver.io
Apache License 2.0
9.23k stars 4.02k forks source link

Issues having upgraded to latest .NET #5488

Closed MCFHTAGENTS closed 2 years ago

MCFHTAGENTS commented 2 years ago

Hi I have upgraded an existing, working, application to .Net 7 and am running IdentityServer 4.1.2. When I start my site I get the following stack trace:

   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.Wait()
System.AggregateException: One or more errors occurred. (The type initializer for 'IdentityServer4.EntityFramework.Mappers.ClientMappers' threw an exception.)
 ---> System.TypeInitializationException: The type initializer for 'IdentityServer4.EntityFramework.Mappers.ClientMappers' threw an exception.
 ---> System.ArgumentException: GenericArguments[0], 'System.Char', on 'T MaxFloat[T](System.Collections.Generic.IEnumerable`1[T])' violates the constraint of type 'T'.
 ---> System.Security.VerificationException: Method System.Linq.Enumerable.MaxFloat: type argument 'System.Char' violates the constraint of type parameter 'T'.
   at System.RuntimeMethodHandle.GetStubIfNeeded(RuntimeMethodHandleInternal method, RuntimeType declaringType, RuntimeType[] methodInstantiation)
   at System.Reflection.RuntimeMethodInfo.MakeGenericMethod(Type[] methodInstantiation)
   --- End of inner exception stack trace ---
   at System.RuntimeType.ValidateGenericArguments(MemberInfo definition, RuntimeType[] genericArguments, Exception e)
   at System.Reflection.RuntimeMethodInfo.MakeGenericMethod(Type[] methodInstantiation)
   at AutoMapper.TypeDetails.<>c__DisplayClass30_1.<BuildPublicNoArgExtensionMethods>b__10(MethodInfo extensionMethod)
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at System.Linq.Enumerable.ConcatIterator`1.MoveNext()
   at System.Linq.Enumerable.SelectManyIterator[TSource,TCollection,TResult](IEnumerable`1 source, Func`2 collectionSelector, Func`3 resultSelector)+MoveNext()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Collections.Generic.HashSet`1.UnionWith(IEnumerable`1 other)
   at System.Linq.Enumerable.UnionIterator`1.FillSet()
   at System.Linq.Enumerable.UnionIterator`1.ToArray()
   at AutoMapper.TypeDetails.BuildPublicNoArgExtensionMethods(IEnumerable`1 sourceExtensionMethodSearch)
   at AutoMapper.TypeDetails..ctor(Type type, ProfileMap config)
   at AutoMapper.ProfileMap.TypeDetailsFactory(Type type)
   at AutoMapper.Internal.LockingConcurrentDictionary`2.<>c__DisplayClass2_1.<.ctor>b__1()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at AutoMapper.Internal.LockingConcurrentDictionary`2.GetOrAdd(TKey key)
   at AutoMapper.ProfileMap.CreateTypeDetails(Type type)
   at AutoMapper.TypeMapFactory.CreateTypeMap(Type sourceType, Type destinationType, ProfileMap options, Boolean isReverseMap)
   at AutoMapper.ProfileMap.BuildTypeMap(IConfigurationProvider configurationProvider, ITypeMapConfiguration config)
   at AutoMapper.ProfileMap.Register(IConfigurationProvider configurationProvider)
   at AutoMapper.MapperConfiguration.Seal()
   at AutoMapper.MapperConfiguration..ctor(MapperConfigurationExpression configurationExpression)
   at AutoMapper.MapperConfiguration..ctor(Action`1 configure)
   at IdentityServer4.EntityFramework.Mappers.ClientMappers..cctor()
   --- End of inner exception stack trace ---
   at IdentityServer4.EntityFramework.Mappers.ClientMappers.ToEntity(Client model)

which occurs in my database initialization routine where I am aligning data held in the confgurationDB with some storage.

foreach (var resource in Config.GetClients(dataSecurity))
                            {
                                var oldClient = await configContext.Clients.Where(a => a.ClientId == resource.ClientId)
                                    .Include(a => a.RedirectUris)
                                    .Include(a => a.ClientSecrets)
                                    .Include(a => a.AllowedScopes)
                                    .Include(a => a.AllowedGrantTypes)
                                    .Include(a => a.AllowedCorsOrigins)
                                    .FirstOrDefaultAsync().ConfigureAwait(false);
                                if (oldClient != null)
                                {
                                    var newClient = resource.ToEntity();

and fails when I call resource.ToEntity. Any ideas what I might need to change?

Thank you

leastprivilege commented 2 years ago

Important update

This organization is not maintained anymore besides critical security bugfixes (if feasible). This organization will be archived when .NET Core 3.1 end of support is reached (3rd Dec 2022). All new development is happening in the new Duende Software organization.

IdentityServer4 is not compatible with .NET 7.

The new Duende IdentityServer comes with a commercial license but is free for dev/testing/personal projects and companies or individuals making less than 1M USD gross annnual revenue. Please get in touch with us if you have any question.

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.