记一个net70mvcwebapi本地编译参数声明模型无法解决的问题多次折腾最后弃坑笔记
简书链接:记一个net70mvcwebapi本地编译参数声明模型无法解决的问题多次折腾最后弃坑笔记
文章字数:303,阅读全文大约需要1分钟
错误概要Microsoft.Extensions.Internal.PropertyHelper.CallNullSafePropertyGetter[webapi.aot.model.GenicQueryCall,System.Int32](System.Func2[webapi.aot.model.GenicQueryCall, System.Int32],System.Object)' is missing native code. MethodInfo.MakeGenericMethod() is not compatible with AOT compilation.
详细
1 | System.NotSupportedException: 'Microsoft.Extensions.Internal.PropertyHelper.CallNullSafePropertyGetter[webapi.aot.model.GenicQueryCall,System.Int32](System.Func2[webapi.aot.model.GenicQueryCall, System.Int32],System.Object)' is missing native code. MethodInfo.MakeGenericMethod() is not compatible with AOT compilation. Inspect and fix AOT related warnings that were generated when the app was published. For more information see https://aka.ms/nativeaot-compatibility |
声明的参数如下:
1 | public string GenericExecCall(GenericCall GenicCall) |
试过编写rd.xml
1 | <Assembly Name="webapi"> |
无法解决
也试过源生成
1 | [JsonSerializable(typeof(GenericParamCall))] |
依然无法解决,我的想法是不让她触发CallNullSafePropertyGetter ,也就是给参数设置默认值,结果并没有卵用
Microsoft.Extensions.Internal.PropertyHelper.CallNullSafePropertyGetter所属dll不知道,试过框架 App作为 dll就去过滤Microsoft.Extensions.Internal.PropertyHelper.CallNullSafePropertyGetter[webapi.aot.model.GenericParamCall,System.Int32]
如
1 | <Assembly Name="到底哪个dll???"> |
问题是不知道属于哪个dll的。
目前能用的是作为接口返回值是ok的,这个时候是不会报错,唯独 作为参数声明不行。
dotnet/src/aspnetcore/src/Shared/PropertyHelper/PropertyHelper.cs at 89eaa42dd7c95b0a1bf62dbaec4ee08b094108d0 · dotnet/dotnet (github.com)