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

时间:2019-03-17 21:31:08

标签: c# json podio

代码

  <?php if ( ! is_single() ) : ?>
<div class="entry-content">
    <?php

    $first_articles = new WP_Query( 
                    array(
                        'posts_per_page' => 2,
                        'numberposts' => 2,
                        'category_name' => 'artykuly',
                        'order'   => 'DESC',
                    ) 
                );

    wp_link_pages( array(
        'before'      => '<div class="page-links">' . __( 'Pages:', 'twentyseventeen' ),
        'after'       => '</div>',
        'link_before' => '<span class="page-number">',
        'link_after'  => '</span>',
    ) );
    ?>

    <?php if ( $first_articles->have_posts() ) : while ( $first_articles->have_posts() ) : $first_articles->the_post(); ?>
    <div class="kat-img" style="background: url('<?php the_post_thumbnail_url(); ?>')">
        <div><?php the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' ); ?></div>
        <div><?php echo excerpt(10); ?></div>
        <div><?php echo get_the_date(); ?></div>
        <div><?php echo the_tags( '<ul><li>', '</li><li>', '</li></ul>' ); ?></div>
    </div>
    <?php endwhile; endif; wp_reset_query(); ?> 

</div><!-- .entry-content -->
<?php endif; ?>

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

appIdValue和appSecretValue是各自的应​​用程序ID及其秘密

运行时错误:

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!");
        }
    }
}

错误列表:

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

我该如何解决这些错误?

1 个答案:

答案 0 :(得分:0)

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