我不确定这里发生了什么,它能够很好地使用 Twitter API 进行身份验证。
但是当它应该发布推文时,会抛出一个
但是当它应该发布推文时,会抛出一个
StackOverflowException
异常,其中显示:
An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll我感到相当困惑。下面的代码是导致异常的原因。
void StartValidation()
{
Console.Clear();
//Start Status thread
var status = TextAndUi.GetStatisThread();
status.Start("Validating");
//Check for Messages
var tweetAndSenderData = Imap.GetUnreadMessageAndSender();
if (tweetAndSenderData != null)
{
//Authurize connection and app
var authenticate = new Authenticate();
var tweetApp = authenticate.CreateClient();
//End thread
status.Abort();
Console.WriteLine("Validated!");
Console.Clear();
//Post tweets
PostContent("test", tweetApp);
//Delete messages
Imap.DeleteMessages();
}
else
{
//End thread
status.Abort();
TextAndUi.ShowSomethingToTheUser("The box is empty, or TTT could not secure a connection", true);
}
}
void PostContent(string myTweet, TwitterService tweetApp)
{
if (TextAndUi.MessageIsSuitableLength(myTweet))
{
PostTweet(tweetApp, myTweet);
}
}
void PostTweet(TwitterService tweetApp, string tweet )
{
var tweetOptions = new SendTweetOptions() {Status = tweet};
tweetApp.SendTweet(tweetOptions); /*The line that throws the exception*
}
使用的库是TweetSharp。
编辑:添加了CallStack数据
mscorlib.dll!System.AppDomain.ExecuteAssembly(string assemblyFile,System.Security.Policy.Evidence assemblySecurity,string [] args)+ 0x6b字节 Microsoft.VisualStudio.HostingProcess.Utilities.dll!Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()+ 0x27字节 mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state)+ 0x6f字节 mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext,System.Threading.ContextCallback callback,object state,bool preserveSyncCtx)+ 0xa7字节 mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext,System.Threading.ContextCallback callback,object state,bool preserveSyncCtx)+ 0x16字节 mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext,System.Threading.ContextCallback callback,object state)+ 0x41字节 mscorlib.dll!System.Threading.ThreadHelper.ThreadStart()+ 0x44字节
a()
调用了方法b()
,然后再次调用了方法a()
(直接或通过一个或多个其他方法间接地调用)。 - Richard Ev