System.FormatException:Base-64 char数组或字符串的长度无效。带空格的字符串

时间:2014-02-17 14:51:27

标签: c# c#-4.0

我相信我已经把问题解决了,但我无法弄清楚如何解决它。这是我的来源:

for (int i = client.GetMessageCount(); i > 0 && iEmailCredit > 0; i--)
{
    OpenPop.Mime.Message unseenMessage = client.GetMessage(i);
    string sFrom = unseenMessage.Headers.From.Address.ToString().ToLower();
    string sName = unseenMessage.Headers.From.DisplayName.ToString().ToLower();
    (...)
}

这是完整的例外:

System.FormatException: Invalid length for a Base-64 char array or string.
at System.Convert.FromBase64_Decode(Char* startInputPtr, Int32 inputLength, Byte* startDestPtr, Int32 destLength)
at System.Convert.FromBase64CharPtr(Char* inputPtr, Int32 inputLength)
at System.Convert.FromBase64String(String s)
at OpenPop.Mime.Decode.Base64.Decode(String base64Encoded)
at OpenPop.Mime.Decode.Base64.Decode(String base64Encoded, Encoding encoding)
at OpenPop.Mime.Decode.EncodedWord.Decode(String encodedWords)
at OpenPop.Mime.Header.RfcMailAddress.ParseMailAddress(String input)
at OpenPop.Mime.Header.MessageHeader.ParseHeader(String headerName, String headerValue)
at OpenPop.Mime.Header.MessageHeader.ParseHeaders(NameValueCollection headers)
at OpenPop.Mime.Header.MessageHeader..ctor(NameValueCollection headers)
at OpenPop.Mime.Header.HeaderExtractor.ExtractHeadersAndBody(Byte[] fullRawMessage, MessageHeader& headers, Byte[]& body)
at OpenPop.Mime.Message..ctor(Byte[] rawMessageContent, Boolean parseBody)
at OpenPop.Mime.Message..ctor(Byte[] rawMessageContent)
at OpenPop.Pop3.Pop3Client.GetMessage(Int32 messageNumber)
at ProcessProject.frmInboxLock.FetchUnseenMessages(String sAspNetUserId, String username, String password, String hostname, Int32 port, Boolean useSsl, Int32 iEmailCredit, String WhiteList, String BlackList) in c:\Users\Chris\Desktop\ServiceProject\ProcessProject\Process.cs:line 277
at ProcessProject.frmInboxLock.FiveMinuteTrigger_Tick(Object sender, EventArgs e) in c:\Users\Chris\Desktop\ServiceProject\ProcessProject\Process.cs:line 618

它说错误发生在“OpenPop.Mime.Message = client ...”的行上,但我相信当我删除“string sName”行时,它会停止抛出错误。我很确定这可能是因为显示名称中的空格,例如“John Doe”。我也在运行一个应用程序,而不是一个网页。请帮助,谢谢,克里斯。

0 个答案:

没有答案