我不确定这里发生了什么,它可以通过 Twitter API 进行身份验证。
但是当它到达应该发布到推特的地步时,它会抛出一个StackOverflowException
说:
“System.StackOverflowException”类型的未处理异常 发生在 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(对象状态)+ 0x6f 字节 mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback 回调, 对象状态, bool preserveSyncCtx) + 0xa7 字节 mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading .ExecutionContext executionContext, System.Threading.ContextCallback 回调, 对象状态, bool preserveSyncCtx) + 0x16 bytes mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback 回调, 对象状态) + 0x41 字节 mscorlib.dll!System.Threading.ThreadHelper.ThreadStart() + 0x44 字节