美文网首页
.NET CORE AOT System.NotSupporte

.NET CORE AOT System.NotSupporte

作者: 吉凶以情迁 | 来源:发表于2023-11-30 15:45 被阅读0次
image.png

Connection id "0HMVI4QB7212P", Request id "0HMVI4QB7212P:00000068": An unhandled exception was thrown by the application.

Exception: 
System.NotSupportedException: 'Microsoft.Extensions.Internal.PropertyHelper+ByRefFunc`2[System.Collections.Generic.KeyValuePair`2[System.String, Microsoft.Extensions.Primitives.StringValues], System.String]' is missing native code or metadata. This can happen for code that is not compatible with trimming or AOT. Inspect and fix trimming and AOT related warnings that were generated when the app was published. For more information see https://aka.ms/nativeaot-compatibility
   at System.Reflection.Runtime.General.TypeUnifier.WithVerifiedTypeHandle(RuntimeConstructedGenericTypeInfo, RuntimeTypeInfo[]) + 0x88
   at Microsoft.Extensions.Internal.PropertyHelper.MakeFastPropertyGetter(Type openGenericDelegateType, MethodInfo propertyGetMethod, MethodInfo openGenericWrapperMethod) + 0x6c
   at Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadataProvider.CreateSinglePropertyDetails(ModelMetadataIdentity propertyKey, PropertyHelper propertyHelper) + 0xec
   at Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadataProvider.CreatePropertyDetails(ModelMetadataIdentity key) + 0xc7
   at Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadataProvider.GetMetadataForProperties(Type modelType) + 0xa9
   at Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadata.get_Properties() + 0x61
   at Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadata.CalculateHasValidators(HashSet`1 visited, ModelMetadata metadata) + 0x1af
   at Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadata.CalculateHasValidators(HashSet`1 visited, ModelMetadata metadata) + 0xdf
   at Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadata.get_HasValidators() + 0x36
   at Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationVisitor.VisitImplementation(ModelMetadata& metadata, String& key, Object model) + 0x15f
   at Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationVisitor.Visit(ModelMetadata metadata, String key, Object model) + 0x5d
   at Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationVisitor.Validate(ModelMetadata metadata, String key, Object model, Boolean alwaysValidateAtTopLevel, Object container) + 0xcd
   at Microsoft.AspNetCore.Mvc.ModelBinding.ObjectModelValidator.Validate(ActionContext actionContext, ValidationStateDictiona

此错误和以往的错误不同,这种错误似乎无法通过rd.xml进行规避,
也不知道怎么 Console.WriteLine(typeof(提前反射修复,
原因是一个form引起,多渠道开发中,不分渠道不需要取post参数,而post参数是后面加上的,

这是一个get参数和post参数共用的写法,然而post参数没必要设置可空

[HttpPost("xxx")]
        public string xxx(int a1,string b="",

            , [FromForm]? IFormCollection formCollection=null,

实际上表单不需要定义可空,我犯了一个低级错误。
可以放到get参数任意位置,取消可空null?放到前面解决了此问题

相关文章

网友评论

      本文标题:.NET CORE AOT System.NotSupporte

      本文链接:https://www.haomeiwen.com/subject/vtuqgdtx.html