Hi. I'm new to asp.net core and to asp.net in general. I am trying to consume a rest service, here is a snippet of code:
return await Task.Run(() => { using (HttpClient client = new HttpClient()) { IEnumerable<T> result = null; var data = client.GetAsync(GetUri()).Result; var jsonResponse = data.Content.ReadAsStringAsync().Result; if (jsonResponse != null) { result = JsonConvert.DeserializeObject<IEnumerable<T>>(jsonResponse); } return result; } });
this issue is the JsonConvert.DeserializeObject, it throws an exception:
Could not load file or assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.
System.Core isn't referenced in the project nor can I reference it. Here is a copy of my .csproj file:
<Project Sdk="Microsoft.NET.Sdk.Web"><PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"><OutputType>exe</OutputType></PropertyGroup><PropertyGroup><TargetFramework>netcoreapp1.1</TargetFramework></PropertyGroup><PropertyGroup><PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback></PropertyGroup><PropertyGroup><UserSecretsId>aspnet-GreenLakeCore-da0d49f4-e6a5-4d81-ad64-77a20dc9af43</UserSecretsId><ApplicationIcon /><OutputTypeEx>exe</OutputTypeEx><StartupObject /></PropertyGroup><ItemGroup><Compile Remove="Data\Migrations\**" /><Content Remove="Data\Migrations\**" /><EmbeddedResource Remove="Data\Migrations\**" /><None Remove="Data\Migrations\**" /></ItemGroup><ItemGroup><Content Include="wwwroot\images\042015-Lenny.jpg" /></ItemGroup><ItemGroup><PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" /><PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" /><PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="1.1.1" /><PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="1.1.1" /><PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="1.1.1" /><PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" /><PackageReference Include="Microsoft.AspNetCore.Mvc.TagHelpers" Version="1.1.2" /><PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" /><PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.1" PrivateAssets="All" /><PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.1" /><PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.1" PrivateAssets="All" /><PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.0" PrivateAssets="All" type="Build" /><PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="1.1.1" /><PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" /><PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="1.1.0" PrivateAssets="All" /><PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.0" /><PackageReference Include="Newtonsoft.Json" Version="10.0.2" /><PackageReference Include="RestSharp.NetCore" Version="105.2.3" /><PackageReference Include="System.ComponentModel.Annotations" Version="4.3.0" /></ItemGroup><ItemGroup><DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" /><DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="1.0.0" /><DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" /></ItemGroup><ItemGroup><None Include="wwwroot\Index.html" /></ItemGroup><ItemGroup><ProjectReference Include="..\Projection\Projection.csproj" /></ItemGroup><ItemGroup><Reference Include="System.Runtime.Serialization"><HintPath>..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.Runtime.Serialization.dll</HintPath></Reference></ItemGroup><ItemGroup><Folder Include="Migrations\" /><Folder Include="Migrations\" /><Folder Include="Migrations\" /></ItemGroup></Project>
There is also system.Runtime.Serialization listed under Assemblies in the Dependencies section.
My question is this:
Is there a problem with NewtonSoft for AspNet core or do I have something wrong in my dependencies?
Thanks