You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 13, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Nov 13, 2026. It is now read-only.
POSTing JSON in the body to bind to a simple POCO model doesn't work when compiled natively. Does this require some additions to the rd.xml file? POSTing to a URL without a model to bind to works just fine.
Now listening on: http://localhost:5000
Now listening on: https://localhost:5001
Application started. Press Ctrl+C to shut down.
fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HLFJBDFV3MEM", Request id "0HLFJBDFV3MEM:00000001": An unhandled exception was thrown by the application.
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Extensions.Internal.PropertyHelper.MakeFastPropertyGetter(Type, MethodInfo, MethodInfo) + 0xb5
at Microsoft.Extensions.Internal.PropertyHelper.MakeFastPropertyGetter(PropertyInfo, MethodInfo, MethodInfo) + 0xbd
at Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadataProvider.CreatePropertyDetails(ModelMetadataIdentity) + 0x173
at Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadataProvider.GetMetadataForProperties(Type) + 0xb2
at Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadata.get_Properties() + 0x46
at Microsoft.AspNetCore.Mvc.ModelBinding.Binders.ComplexTypeModelBinderProvider.GetBinder(ModelBinderProviderContext) + 0x67
at Microsoft.AspNetCore.Mvc.ModelBinding.ModelBinderFactory.CreateBinderCoreUncached(ModelBinderFactory.DefaultModelBinderProviderContext, Object) + 0x111
at Microsoft.AspNetCore.Mvc.ModelBinding.ModelBinderFactory.CreateBinder(ModelBinderFactoryContext) + 0x7d
at Microsoft.AspNetCore.Mvc.Internal.ControllerBinderDelegateProvider.GetParameterBindingInfo(IModelBinderFactory, IModelMetadataProvider, ControllerActionDescriptor, MvcOptions) + 0x147
at Microsoft.AspNetCore.Mvc.Internal.ControllerBinderDelegateProvider.CreateBinderDelegate(ParameterBinder, IModelBinderFactory, IModelMetadataProvider, ControllerActionDescriptor, MvcOptions) + 0x84
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvokerCache.GetCachedResult(ControllerContext) + 0xe0
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvokerProvider.OnProvidersExecuting(ActionInvokerProviderContext) + 0x94
at Microsoft.AspNetCore.Mvc.Internal.ActionInvokerFactory.CreateInvoker(ActionContext) + 0x52
at Microsoft.AspNetCore.Mvc.Internal.MvcAttributeRouteHandler.<>c__DisplayClass12_0.<RouteAsync>b__0(HttpContext) + 0x98
at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext() + 0x382
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x1b
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.<ProcessRequests>d__186`1.MoveNext() + 0x732
After many hours of frustration, it seems to have just started working. In the end, I don't believe I'm doing anything that isn't in the WebApi example.
This is probably because we didn't compile a property since it wasn't statically used by the program. The CoreRT compiler only compiles things that are statically used, or specified in RD.XML.
I submitted #6149 that should make troubleshooting this easier. Once this is merged and a new ILCompiler package is out, you can add <IlcArg Include="--completetypemetadata" /> into one of your project's ItemGroups and you should get a more actionable exception. (You'll still need to mess with RD.XML to fix the actual problem, but it should be more obvious what's missing.)
@MichalStrehovsky I tested this with a few changes to the sample webapi and receive the same error. Wouldn't the static reference to the SimpleModel property in the POST method mark it for compilation? What else would need to be added to rd.xml?:
public class SimpleModel
{
public string Name { get; set; }
}
[HttpPost("/api/values")]
public string Post([FromBody] SimpleModel model)
{
return model.Name;
}
If the property being reflected on is in the SampleWebApi assembly, this would be a bug somewhere. But from the stack trace it's not clear what property is the ASP.NET Core stack trying to reflect on. This will be easiest to root cause when the new ILCompiler package with the --completetypemetadata switch support comes out in a couple hours.
@MichalStrehovsky Using the new versions yields this error. I've tried adding the type specified using the URL in the error but still end up with build errors. How should this type be added to rd.xml?:
fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HLFM7GNSSSGI", Request id "0HLFM7GNSSSGI:00000001": An unhandled exception was thrown by the application.
EETypeRva:0x01FAA158: MakeGenericMethod() cannot create this generic method instantiation because the instantiation was not metadata-enabled: 'Microsoft.Extensions.Internal.PropertyHelper.CallNullSafePropertyGetter<SampleWebApi.Controllers.SimpleModel,System.String>(Syst
em.Func<SampleWebApi.Controllers.SimpleModel,System.String>,System.Object)' For more information, please visit http://go.microsoft.com/fwlink/?LinkID=616868
at SampleWebApi!<BaseAddress>+0x22c5b3
at SampleWebApi!<BaseAddress>+0x53e970
at SampleWebApi!<BaseAddress>+0xaf1ffe
at SampleWebApi!<BaseAddress>+0x4e2fa6
at SampleWebApi!<BaseAddress>+0x510be3
at SampleWebApi!<BaseAddress>+0xaf164e
at Microsoft.Extensions.Internal.PropertyHelper.MakeFastPropertyGetter(Type, MethodInfo, MethodInfo) + 0x174
at Microsoft.Extensions.Internal.PropertyHelper.MakeFastPropertyGetter(PropertyInfo, MethodInfo, MethodInfo) + 0x108
at Microsoft.Extensions.Internal.PropertyHelper.MakeNullSafeFastPropertyGetter(PropertyInfo) + 0x4d
at Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadataProvider.CreatePropertyDetails(ModelMetadataIdentity) + 0x29e
at Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadataProvider.GetMetadataForProperties(Type) + 0x13a
at Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadata.get_Properties() + 0x64
at Microsoft.AspNetCore.Mvc.Internal.DefaultComplexObjectValidationStrategy.GetChildren(ModelMetadata, String, Object) + 0x3a
at Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationVisitor.VisitChildren(IValidationStrategy) + 0x96
at Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationVisitor.VisitComplexType(IValidationStrategy) + 0xea
at Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationVisitor.Visit(ModelMetadata, String, Object) + 0x435
at Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationVisitor.Validate(ModelMetadata, String, Object, Boolean) + 0xd8
at Microsoft.AspNetCore.Mvc.ModelBinding.ObjectModelValidator.Validate(ActionContext, ValidationStateDictionary, String, Object) + 0x11d
at Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder.<BindModelAsync>d__11.MoveNext() + 0x863
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x31
at SampleWebApi!<BaseAddress>+0xa05532
at SampleWebApi!<BaseAddress>+0xa0544d
at SampleWebApi!<BaseAddress>+0xa053aa
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() + 0x23
at Microsoft.AspNetCore.Mvc.Internal.ControllerBinderDelegateProvider.<>c__DisplayClass0_0.<<CreateBinderDelegate>g__Bind|0>d.MoveNext() + 0x39c
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x31
at SampleWebApi!<BaseAddress>+0xa05532
at SampleWebApi!<BaseAddress>+0xa0544d
at SampleWebApi!<BaseAddress>+0xa053aa
at System.Runtime.CompilerServices.TaskAwaiter.GetResult() + 0x19
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeInnerFilterAsync>d__13.MoveNext() + 0x148
The URL in the exception message points to the "official" RD.XML syntax. The CoreRT compiler speaks a weird dialect. The format is described here: #4775
Is there a way to output the assembly in this error? This class and method isn't documented with Microsoft and I am having difficulty locating the assembly it resides in.
The place where you're putting System.String should be an assembly name (SampleWebApi, I assume). The System.String should be a separate GenericArgument (assembly qualified with System.Runtime).
I would use a tool such as ILSpy to find the assembly. You can drag/drop all the assemblies into the UI and use Ctrl-F to find the type by name.
Fantastic, this ended up working for those errors. Is there currently a way around having to specify this for each of the classes you are using for model binding?:
Is there currently a way around having to specify this for each of the classes you are using for model binding
If these are reference types (which it seems they are), you don't need to specify this for each property. Generic instantiations over reference types share native code, so we don't need to know exactly what will be used. The runtime can manufacture the types on the go (the problem is really only about having the native code available).
Should also work, and is a bit more flexible because it avoids hardcoding the SampleWebApi string.
If you have a complete set of RD.XML that is needed to enable this in the SampleWebApi project, it would be great if you could contribute it in a form of a pull request to help others.
Activity
mattvaughan commentedon Jul 27, 2018
After many hours of frustration, it seems to have just started working. In the end, I don't believe I'm doing anything that isn't in the WebApi example.
mattvaughan commentedon Jul 28, 2018
I was mistaken. The original issue is still a problem
MichalStrehovsky commentedon Jul 29, 2018
This is probably because we didn't compile a property since it wasn't statically used by the program. The CoreRT compiler only compiles things that are statically used, or specified in RD.XML.
I submitted #6149 that should make troubleshooting this easier. Once this is merged and a new ILCompiler package is out, you can add
<IlcArg Include="--completetypemetadata" />into one of your project'sItemGroups and you should get a more actionable exception. (You'll still need to mess with RD.XML to fix the actual problem, but it should be more obvious what's missing.)mattvaughan commentedon Jul 29, 2018
@MichalStrehovsky I tested this with a few changes to the sample webapi and receive the same error. Wouldn't the static reference to the
SimpleModelproperty in the POST method mark it for compilation? What else would need to be added tord.xml?:MichalStrehovsky commentedon Jul 30, 2018
If the property being reflected on is in the
SampleWebApiassembly, this would be a bug somewhere. But from the stack trace it's not clear what property is the ASP.NET Core stack trying to reflect on. This will be easiest to root cause when the new ILCompiler package with the--completetypemetadataswitch support comes out in a couple hours.mattvaughan commentedon Jul 30, 2018
@MichalStrehovsky Using the new versions yields this error. I've tried adding the type specified using the URL in the error but still end up with build errors. How should this type be added to rd.xml?:
MichalStrehovsky commentedon Jul 30, 2018
The URL in the exception message points to the "official" RD.XML syntax. The CoreRT compiler speaks a weird dialect. The format is described here: #4775
mattvaughan commentedon Jul 30, 2018
Is there a way to output the assembly in this error? This class and method isn't documented with Microsoft and I am having difficulty locating the assembly it resides in.
Microsoft.Extensions.Internal.PropertyHelper.CallNullSafePropertyGetterA
grepof the.dllfiles inrefsyields some results, but adding those toRD.XMLdidn't solve the issue.Following the syntax in the issue you posted, I came up with:
MichalStrehovsky commentedon Jul 30, 2018
The place where you're putting
System.Stringshould be an assembly name (SampleWebApi, I assume). TheSystem.Stringshould be a separateGenericArgument(assembly qualified withSystem.Runtime).I would use a tool such as ILSpy to find the assembly. You can drag/drop all the assemblies into the UI and use Ctrl-F to find the type by name.
mattvaughan commentedon Jul 30, 2018
Fantastic, this ended up working for those errors. Is there currently a way around having to specify this for each of the classes you are using for model binding?:
MichalStrehovsky commentedon Jul 31, 2018
If these are reference types (which it seems they are), you don't need to specify this for each property. Generic instantiations over reference types share native code, so we don't need to know exactly what will be used. The runtime can manufacture the types on the go (the problem is really only about having the native code available).
Should also work, and is a bit more flexible because it avoids hardcoding the
SampleWebApistring.If you have a complete set of RD.XML that is needed to enable this in the SampleWebApi project, it would be great if you could contribute it in a form of a pull request to help others.
mattvaughan commentedon Jul 31, 2018
@MichalStrehovsky Sounds great! I'll continue to refine the RD.XML and once I feel it is in a good place, I'll submit a PR.