Open adzhiljano opened 2 years ago
Older .NET framework versions are going out of support soon. Shipping Core with .NET framework 4.6.2 should allow us to consume System.Text.Json from Core for all versions, which should solve this probably.
@corranrogue9 Any updates on this issue? After updating some dependencies I had to update Microsoft.AspNet.OData
or else a MapODataServiceRoute
call would throw an exception. But after the update I am facing the above error message.
Having an ASP.NET WebAPI project, targeting
net472
(which implementsnetstandard2.0
), and having the latest OData packages when trying to dohost/$metadata?$format=json
I get the following error:The JSON metadata is not supported at this platform. It's only supported at platform implementing .NETStardard 2.0.
Assemblies affected
Microsoft.AspNet.OData 7.5.14 Microsoft.OData.Core 7.10.0 Microsoft.OData.Edm 7.10.0 Microsoft.Spatial 7.10.0
Reproduce steps
Follow the guide at https://docs.microsoft.com/en-us/aspnet/web-api/overview/odata-support-in-aspnet-web-api/odata-v4/create-an-odata-v4-endpoint and do a
host/$metadata?$format=json
request.Expected result
Get the metadata in JSON format
Actual result
Additional detail
The error comes from the
Microsoft.OData.Core
lib, which has 3 distributions (net45
,netstandard1.1
,netstandard2.0
) and it seems that the JSON format is supported only in thenetstandard2.0
dist. When installingMicrosoft.AspNet.OData
via NuGet from anet45(46/47/48)
project, it looks like thenet45
ofMicrosoft.OData.Core
lib will be the preferred one. Because of that, I think effectively there is no support for JSON metadata.I made it work by manually changing the
<HintPath>
in the csproj fromto
but this won't last a reinstall.
Is there a way to force the
netstandard2.0
dist to be used, which will survive aUpdate-Package -reinstall
? Or the JSON metadata format is not supported forMicrosoft.AspNet.OData
by design?