【问题标题】:IdentityServer4 dotnet7 produce exceptionIdentityServer4 dotnet7 产生异常
【发布时间】:2023-02-10 21:22:27
【问题描述】:

当使用 Automaper 10.1.1、identityserver4 和 .net 7 时,identityserver4 是 IdentityServer 的最后一个免费版本并且不能与更高版本的 AutoMapper 一起使用,此链接中解决了此问题:Issue。 Automapper 10 + 身份服务器 4 + dotnet 7 只是当我点击 /.well-known/openid-configuration 时,我得到了这个异常

ArgumentException: GenericArguments[0], 'System.Char', on 'T MaxFloat[T](System.Collections.Generic.IEnumerable`1[T])' violates the constraint of type 'T'.
System.RuntimeType.ValidateGenericArguments(MemberInfo definition, RuntimeType[] genericArguments, Exception e)
System.Reflection.RuntimeMethodInfo.MakeGenericMethod(Type[] methodInstantiation)
AutoMapper.TypeDetails+<>c__DisplayClass28_1.<BuildPublicNoArgExtensionMethods>b__10(MethodInfo extensionMethod)
System.Linq.Enumerable+WhereSelectArrayIterator<TSource, TResult>.MoveNext()
System.Linq.Enumerable+ConcatIterator<TSource>.MoveNext()
System.Linq.Enumerable.SelectManyIterator<TSource, TCollection, TResult>(IEnumerable<TSource> source, Func<TSource, IEnumerable<TCollection>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)+MoveNext()
System.Linq.Enumerable+WhereSelectEnumerableIterator<TSource, TResult>.MoveNext()
System.Collections.Generic.HashSet<T>.UnionWith(IEnumerable<T> other)
System.Linq.Enumerable+UnionIterator<TSource>.FillSet()
System.Linq.Enumerable+UnionIterator<TSource>.ToArray()
AutoMapper.TypeDetails.BuildPublicNoArgExtensionMethods(IEnumerable<MethodInfo> sourceExtensionMethodSearch)
AutoMapper.TypeDetails..ctor(Type type, ProfileMap config)
AutoMapper.ProfileMap.TypeDetailsFactory(Type type)
AutoMapper.Internal.LockingConcurrentDictionary<TKey, TValue>+<>c__DisplayClass2_1.<.ctor>b__1()
System.Lazy<T>.ViaFactory(LazyThreadSafetyMode mode)
System.Lazy<T>.ExecutionAndPublication(LazyHelper executionAndPublication, bool useDefaultConstructor)
System.Lazy<T>.CreateValue()
AutoMapper.Internal.LockingConcurrentDictionary<TKey, TValue>.GetOrAdd(TKey key)
AutoMapper.ProfileMap.CreateTypeDetails(Type type)
AutoMapper.TypeMapFactory.CreateTypeMap(Type sourceType, Type destinationType, ProfileMap options, bool isReverseMap)
AutoMapper.ProfileMap.BuildTypeMap(IConfigurationProvider configurationProvider, ITypeMapConfiguration config)
AutoMapper.ProfileMap.Register(IConfigurationProvider configurationProvider)
AutoMapper.MapperConfiguration.Seal()
AutoMapper.MapperConfiguration..ctor(MapperConfigurationExpression configurationExpression)
AutoMapper.MapperConfiguration..ctor(Action<IMapperConfigurationExpression> configure)
IdentityServer4.EntityFramework.Mappers.IdentityResourceMappers..cctor()
// Put your source/destination types here

我尝试了所有更高版本,但我得到了另一个异常,因为身份服务器 4 需要 AutoMapper 版本>=10 和 <11,在这种情况下,我得到了这个异常:

System.MissingMethodException: Method not found: '!2 AutoMapper.IMappingExpressionBase`3.ConstructUsing(System.Linq.Expressions.Expression`1<System.Func`2<!0,!1>>)'.
   at IdentityServer4.EntityFramework.Mappers.ClientMapperProfile..ctor()
   at System.RuntimeType.CreateInstanceOfT()

【问题讨论】:

  • 您可以拥有自己的 IdentityServer4.EntityFramework 或 AutoMapper 分支。

标签: c# migration automapper identityserver4 .net-7.0


【解决方案1】:

我昨天也看到了这个问题 - 花了很多时间寻找解决方案但没有找到。 I decided to downgrade .net to 6.0 然后它起作用了——不过,IS4.EF.Storage 的要求提到了对 .net 7.0 的支持

也许你应该看看Duende.IdentityServer

这是 IS4 的创建者创建的新公司。可能问题已经在那里解决了。由于它们的相似性,从 IS4 切换到 Duende 应该不难

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-01-31
    • 1970-01-01
    • 2019-03-01
    • 2013-08-05
    • 1970-01-01
    • 2017-08-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多