我在PodioApi C#System.IO.FileNotFoundException中遇到了运行时错误

问题描述 投票:0回答:1

Code

using System;
using PodioAPI;

namespace TestPodio
{
    class Program
    {
        static void Main(string[] args)
        {
            string clientId = clientIdValue; 
            string clientSecret = clientSecretValue;
            int appId = appIdValue;
            string appSecret = appSecretValue;
            var podio = new Podio(clientId, clientSecret);

            podio.AuthenticateWithApp(appId, appSecret);
            var items = podio.ItemService.FilterItems(appId);

            Console.WriteLine("My app has " + items.Total + " items");
            //Console.WriteLine("Hello World!");
        }
    }
}

clientIdValue和clientSecretValue是我正在使用的客户端ID和客户端密钥

appIdValue和appSecretValue是相应的应用程序ID及其秘密

Runtime error:

System.IO.FileNotFoundException
HResult=0x80070002
Message=Could not load file or assembly 'System.Security.Permissions, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. Den angivne fil blev ikke fundet.
Source=Newtonsoft.Json
StackTrace:
 at Newtonsoft.Json.Serialization.JsonTypeReflector.get_DynamicCodeGeneration()
 at Newtonsoft.Json.Serialization.JsonTypeReflector.get_ReflectionDelegateFactory()
 at Newtonsoft.Json.Serialization.DefaultContractResolver.GetDefaultCreator(Type createdType)
 at Newtonsoft.Json.Serialization.DefaultContractResolver.InitializeContract(JsonContract contract)
 at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateObjectContract(Type objectType)
 at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract(Type objectType)
 at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract(Type type)
 at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
 at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
 at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonConverter[] converters)
 at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
 at PodioAPI.Podio.Request[T](RequestMethod requestMethod, String url, Object requestData, Object options)
 at System.Dynamic.UpdateDelegates.UpdateAndExecute5[T0,T1,T2,T3,T4,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
 at PodioAPI.Podio.Post[T](String url, Object requestData, Object options)
 at PodioAPI.Podio.Authenticate(String grantType, Dictionary`2 attributes)
 at PodioAPI.Podio.AuthenticateWithApp(Int32 appId, String appToken)
 at TestPodio.Program.Main(String[] args) in C:\Users\HHM\Documents\Visual Studio 2017\Projects\TestPodio\TestPodio\Program.cs:line 16

Error list:

Severity  Code  Description Project File  Line  Suppression State
Warning NU1701  Package 'Newtonsoft.Json 5.0.8' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.1'. This package may not be fully compatible with your project. TestPodio C:\Users\HHM\Documents\Visual Studio 2017\Projects\TestPodio\TestPodio\TestPodio.csproj 1 
Warning NU1701  Package 'Podio 1.5.9' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.1'. This package may not be fully compatible with your project. TestPodio C:\Users\HHM\Documents\Visual Studio 2017\Projects\TestPodio\TestPodio\TestPodio.csproj 1 

我该如何解决这些错误?

c# json podio
1个回答
0
投票

问题是你已经创建了一个dotnet核心项目,但是podio是一个dotnet框架项目。尝试将项目重新创建为dotnet框架项目。当你创建新项目时,而不是Console App (.NET Core)选择Console App (.NET Framework)

© www.soinside.com 2019 - 2024. All rights reserved.