Repro:
1. Download ODataServiceSample
2. Upgrade odata package to myget latest: http://www.myget.org/F/aspnetwebstacknightly/
3. Start service
4. Send request: http://localhost:50231/ProductFamilies(1)/$links/Products
5. Server never returns back
When debugging, it shows following error:
System.Reflection.TargetException occurred
HResult=-2146232829
Message=Object does not match target type.
Source=mscorlib
StackTrace:
at System.Reflection.RuntimeMethodInfo.CheckConsistency(Object target)
InnerException:
mscorlib.dll!System.Reflection.RuntimeMethodInfo.CheckConsistency(object target)
> System.Web.Http.OData.dll!System.Web.Http.OData.Builder.Conventions.ConventionsHelpers.GetUriRepresentationForKeyValue(System.Reflection.PropertyInfo key, object entityInstance) Line 156 C#
System.Web.Http.OData.dll!System.Web.Http.OData.Builder.Conventions.ConventionsHelpers.GetEntityKeyValue(System.Web.Http.OData.EntityInstanceContext entityContext, System.Web.Http.OData.Builder.IEntityTypeConfiguration entityTypeConfiguration) Line 56 C#
System.Web.Http.OData.dll!System.Web.Http.OData.Builder.Conventions.SelfLinksGenerationConvention.Apply.AnonymousMethod__1(System.Web.Http.OData.EntityInstanceContext entityContext) Line 52 C#
System.Web.Http.OData.dll!System.Web.Http.OData.Builder.EntitySetLinkBuilderAnnotation.BuildEditLink(System.Web.Http.OData.EntityInstanceContext context) Line 88 C#
System.Web.Http.OData.dll!System.Web.Http.OData.Builder.EntitySetLinkBuilderAnnotation.BuildIdLink(System.Web.Http.OData.EntityInstanceContext context) Line 70 C#
System.Web.Http.OData.dll!System.Web.Http.OData.Formatter.Serialization.ODataEntityTypeSerializer.WriteEntry(object graph, System.Collections.Generic.IEnumerable<Microsoft.Data.OData.ODataProperty> propertyBag, Microsoft.Data.OData.ODataWriter writer, System.Web.Http.OData.Formatter.Serialization.ODataSerializerContext writeContext) Line 82 C#
System.Web.Http.OData.dll!System.Web.Http.OData.Formatter.Serialization.ODataEntityTypeSerializer.WriteObjectInline(object graph, Microsoft.Data.OData.ODataWriter writer, System.Web.Http.OData.Formatter.Serialization.ODataSerializerContext writeContext) Line 59 C#
System.Web.Http.OData.dll!System.Web.Http.OData.Formatter.Serialization.ODataEntityTypeSerializer.WriteObject(object graph, Microsoft.Data.OData.ODataMessageWriter messageWriter, System.Web.Http.OData.Formatter.Serialization.ODataSerializerContext writeContext) Line 40 C#
System.Web.Http.OData.dll!System.Web.Http.OData.Formatter.ODataMediaTypeFormatter.WriteToStreamAsync.AnonymousMethod__5() Line 291 C#
System.Web.Http.OData.dll!System.Threading.Tasks.TaskHelpers.RunSynchronously(System.Action action, System.Threading.CancellationToken token) Line 207 C#
System.Web.Http.OData.dll!System.Web.Http.OData.Formatter.ODataMediaTypeFormatter.WriteToStreamAsync(System.Type type, object value, System.IO.Stream writeStream, System.Net.Http.HttpContent content, System.Net.TransportContext transportContext) Line 220 C#
1. Download ODataServiceSample
2. Upgrade odata package to myget latest: http://www.myget.org/F/aspnetwebstacknightly/
3. Start service
4. Send request: http://localhost:50231/ProductFamilies(1)/$links/Products
5. Server never returns back
When debugging, it shows following error:
System.Reflection.TargetException occurred
HResult=-2146232829
Message=Object does not match target type.
Source=mscorlib
StackTrace:
at System.Reflection.RuntimeMethodInfo.CheckConsistency(Object target)
InnerException:
mscorlib.dll!System.Reflection.RuntimeMethodInfo.CheckConsistency(object target)
> System.Web.Http.OData.dll!System.Web.Http.OData.Builder.Conventions.ConventionsHelpers.GetUriRepresentationForKeyValue(System.Reflection.PropertyInfo key, object entityInstance) Line 156 C#
System.Web.Http.OData.dll!System.Web.Http.OData.Builder.Conventions.ConventionsHelpers.GetEntityKeyValue(System.Web.Http.OData.EntityInstanceContext entityContext, System.Web.Http.OData.Builder.IEntityTypeConfiguration entityTypeConfiguration) Line 56 C#
System.Web.Http.OData.dll!System.Web.Http.OData.Builder.Conventions.SelfLinksGenerationConvention.Apply.AnonymousMethod__1(System.Web.Http.OData.EntityInstanceContext entityContext) Line 52 C#
System.Web.Http.OData.dll!System.Web.Http.OData.Builder.EntitySetLinkBuilderAnnotation.BuildEditLink(System.Web.Http.OData.EntityInstanceContext context) Line 88 C#
System.Web.Http.OData.dll!System.Web.Http.OData.Builder.EntitySetLinkBuilderAnnotation.BuildIdLink(System.Web.Http.OData.EntityInstanceContext context) Line 70 C#
System.Web.Http.OData.dll!System.Web.Http.OData.Formatter.Serialization.ODataEntityTypeSerializer.WriteEntry(object graph, System.Collections.Generic.IEnumerable<Microsoft.Data.OData.ODataProperty> propertyBag, Microsoft.Data.OData.ODataWriter writer, System.Web.Http.OData.Formatter.Serialization.ODataSerializerContext writeContext) Line 82 C#
System.Web.Http.OData.dll!System.Web.Http.OData.Formatter.Serialization.ODataEntityTypeSerializer.WriteObjectInline(object graph, Microsoft.Data.OData.ODataWriter writer, System.Web.Http.OData.Formatter.Serialization.ODataSerializerContext writeContext) Line 59 C#
System.Web.Http.OData.dll!System.Web.Http.OData.Formatter.Serialization.ODataEntityTypeSerializer.WriteObject(object graph, Microsoft.Data.OData.ODataMessageWriter messageWriter, System.Web.Http.OData.Formatter.Serialization.ODataSerializerContext writeContext) Line 40 C#
System.Web.Http.OData.dll!System.Web.Http.OData.Formatter.ODataMediaTypeFormatter.WriteToStreamAsync.AnonymousMethod__5() Line 291 C#
System.Web.Http.OData.dll!System.Threading.Tasks.TaskHelpers.RunSynchronously(System.Action action, System.Threading.CancellationToken token) Line 207 C#
System.Web.Http.OData.dll!System.Web.Http.OData.Formatter.ODataMediaTypeFormatter.WriteToStreamAsync(System.Type type, object value, System.IO.Stream writeStream, System.Net.Http.HttpContent content, System.Net.TransportContext transportContext) Line 220 C#