I got a runtime error in PodioApi C# System.IO.FileNotFoundException

0

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 and clientSecretValue are the client id and client secret i'm using

appIdValue and appSecretValueare the respective app id and its secret

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 

How do I solve these errors?

c#
json
podio
asked on Stack Overflow Mar 17, 2019 by hhmaanson • edited Mar 18, 2019 by Akbar Badhusha

1 Answer

0

The problem is you've created a dotnet core project, but podio is a dotnet framework project. Try recreating your project as a dotnet framework project instead. Instead of Console App (.NET Core) choose Console App (.NET Framework) when you create new project.

answered on Stack Overflow Mar 17, 2019 by Ben

User contributions licensed under CC BY-SA 3.0