2017-09-18 1 views
4

Hier ist der Code meiner .net Core 2.0 Konsole App:ServiceStack Json Deserialisierung Fehler

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; } 
    } 
} 

Wenn ich ausführen, um die Anwendung, die ich die folgende Ausnahme erhalten:

System.TypeInitializationException: 'Der Typinitialisierer für ' ServiceStack.Text.JsonSerializer 'hat eine Ausnahme ausgelöst.'

FileNotFoundException: Kann nicht Datei oder Assembly 'System.Configuration.ConfigurationManager, Version = 0.0.0.0, Culture = neutral, PublicKeyToken = cc7b13ffcd2ddd51' laden. Das System kann die angegebene Datei nicht finden.

Wie kann ich das beheben?

+0

'dotnet restore'? –

Antwort

4

Sie verwenden wahrscheinlich das falsche NuGet-Paket ServiceStack.Text, wenn Sie sich auf ServiceStack.Text.Core beziehen sollten.