4
votes

Here is the code of my .net core 2.0 console app:

using ServiceStack;
using System;
using System.Collections.Generic;

namespace ConsoleApp1
{
     class Program
     {
         static void Main(string[] args)
         {
             var response = $"http://capfeed.com/json"
                 .GetJsonFromUrl(httpReq => httpReq.UserAgent = "Hoho")
                 .FromJson<CapFeedResponse>();

             Console.ReadKey();
         }
     }

     public class CapFeedResponse
     {
         public string success { get; set; }

         public string message { get; set; }

         public List<CapFeedResponseItem> result { get; set; }
     }

     public class CapFeedResponseItem
     {
          public int position { get; set; }

          public string symbol { get; set; }

          public string name { get; set; }

          public long time { get; set; }

          public decimal usdPrice { get; set; }

          public decimal btcPrice { get; set; }

          public long usdVolume { get; set; }

          public long mktcap { get; set; }

          public long supply { get; set; }

          public float change24 { get; set; }
     }
 }

When I run the application I'm getting the following exception:

System.TypeInitializationException: 'The type initializer for 'ServiceStack.Text.JsonSerializer' threw an exception.'

FileNotFoundException: Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.

How can I fix this?

1
dotnet restore?J. Doe

1 Answers

4
votes

You're likely using the wrong ServiceStack.Text NuGet package when you should be referencing ServiceStack.Text.Core.