2013-03-20 29 views
2

任何我在Mono上遇到這個錯誤的原因,但不是在Windows上?使用單聲道錯誤格式異常,但不在窗口上

Unhandled Exception: System.FormatException: Invalid format string 
at System.DateTime.ParseExact (string,string[],System.IFormatProvider,System.Glo                           balization.DateTimeStyles) <0x00127> 
at System.DateTime.ParseExact (string,string,System.IFormatProvider,System.Globa                       lization.DateTimeStyles) <0x0004f> 
at System.DateTime.ParseExact (string,string,System.IFormatProvider) <0x0001f> 
at (wrapper dynamic-method) object.CallSite.Target (System.Runtime.CompilerServi                      ces.Closure,System.Runtime.CompilerServices.CallSite,System.Type,object,string,S                      ystem.Globalization.DateTimeFormatInfo) <0x000f3> 
at System.Dynamic.UpdateDelegates.UpdateAndExecute4<System.Type, object, string,                       System.Globalization.DateTimeFormatInfo, object> (System.Runtime.CompilerServic                       es.CallSite,System.Type,object,string,System.Globalization.DateTimeFormatInfo) <                        0x00418> 
at TwitterScraper.Program.scrapeTwitter() <0x00a22> 
at TwitterScraper.Program.Main (string[]) <0x000bf> 

這個代碼在這裏

DateTime tweettime = DateTime.ParseExact(obj["created_at"].ToString(), 
     "ddd MMM dd HH:mm:ss %K yyyy", 
     CultureInfo.InvariantCulture.DateTimeFormat); 

這是用來處理時間格式的Twitter給你。

回答

1

試試這個:

DateTimeOffset tweettime = DateTimeOffset.ParseExact(yourInputString, 
    "ddd MMM dd HH:mm:ss zzz yyyy", CultureInfo.InvariantCulture);