【发布时间】:2016-09-18 20:56:57
【问题描述】:
我目前正在探索我的第一个第三方库,一切正常,除了它应该在出现错误时向我抛出错误,而它没有..
这是我的代码,我已经尝试过导致错误,但它应该会导致错误,但事实并非如此,应用程序仍在运行
例如,当我从消费者密钥中删除一个字母或数字时,它没有连接,它应该给我一个错误。
我正在查看文档并尝试遵循此操作
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Tweetinvi;
using Tweetinvi.Core.Authentication;
using Tweetinvi.Core;
using Tweetinvi.Credentials;
using Tweetinvi.WebLogic;
namespace Tweetinvi
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string accessToken;
string accessTokenSecret;
string consumerKey;
string consumerSecret;
string hashTag;
string userName;
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
try
{
Auth.SetUserCredentials(consumerKeyBox.Text, consumerSecretBox.Text, accessTokenBox.Text, accessTokenSecretBox.Text);
Tweet.PublishTweet("Hello World :)");
//User.UnFollowUser("");
}
catch(Exception ex)
{
MessageBox.Show("Something went wrong");
}
}
}
}
【问题讨论】:
-
应该出了什么问题?
-
您是在
Release模式还是Debug模式下运行程序? -
在使用第三方库时,一定要阅读documentation以确认您的期望与现实。默认情况下,TweetInvi 会吞下异常。这应该由返回包含异常的
null和ExceptionHandler.GetLastException()的Tweet.PublishTweet()指示。
标签: c# .net linq twitter tweetinvi