Forums NntpBridge and DateTime

There is a “research” project to access the msdn-web forums via a nntp-bridge. The offical version is “V1″… but I must say, that it is still Beta1 ๐Ÿ˜‰

For example, there is a bug with the DateTime-Format, which uses the current system locale… This bug was reported severaly months ago, and nothing happend… In january and february it was not a problem, because “Jan” and “Feb” are the same in english and german… but in “Mรคrz” the NntpBridge started to report all postings with “01.01.1970 01:00″… because it will report the date as “Mrz” instead of “Mar”… which is somehow bad…

So I decided to make a quick fix for this behavior. You just need to add the System.Globalization.CultureInfo.InvariantCulture as parameter to the ToString method.

Here are the steps, how you can fix this by yourself:

  1. Locale the directory of the Nntp-Bridge (normally “C:\Program Files (x86)\Microsoft Community Tools\Microsoft Forums NNTP Bridge”
  2. Copy the file “nntp.dll” to “nntp_org.dll” so you have the original version saved
  3. Copy “nntp.dll” into a temporary directory like “c:\temp\nntp_fix”
  4. Open a “Visual Studio 2005/2008 Command Prompt (x86)”
  5. Go to the temporary directory (cd /D c:\temp\nntp_fix)
  6. Disassemble the nntp.dll
    ildasm nntp.dll /out=nntp.il
  7. Now you need to change the content of the nntp.il file
  8. Find the method “GetMessageFormat” and change it from
    .method public hidebysig static string  GetMessageFormat(valuetype [mscorlib]System.DateTime dateTime) cil managed
    {
      // Code size       28 (0x1c)
      .maxstack  8
      IL_0000:  ldstr      "{0} {1}"
      IL_0005:  ldarga.s   dateTime
      IL_0007:  ldstr      "ddd, d MMM yyyy HH:mm:ss"
      IL_000c:  call       instance string [mscorlib]System.DateTime::ToString(string)
      IL_0011:  ldsfld     string Nntp.NntpTimeUtility::GmtTimeZoneOffset
      IL_0016:  call       string [mscorlib]System.String::Format(string,
                                                                  object,
                                                                  object)
      IL_001b:  ret
    } // end of method NntpTimeUtility::GetMessageFormat
    

    to

    .method public hidebysig static string  GetMessageFormat(valuetype [mscorlib]System.DateTime dateTime) cil managed
    {
      // Code size       33 (0x21)
      .maxstack  8
      IL_0000:  ldstr      "{0} {1}"
      IL_0005:  ldarga.s   dateTime
      IL_0007:  ldstr      "ddd, d MMM yyyy HH:mm:ss"
      IL_000c:  call       class [mscorlib]System.Globalization.CultureInfo [mscorlib]System.Globalization.CultureInfo::get_InvariantCulture()
      IL_0011:  call       instance string [mscorlib]System.DateTime::ToString(string,
                                                                               class [mscorlib]System.IFormatProvider)
      IL_0016:  ldsfld     string Nntp.NntpTimeUtility::GmtTimeZoneOffset
      IL_001b:  call       string [mscorlib]System.String::Format(string,
                                                                  object,
                                                                  object)
      IL_0020:  ret
    } // end of method NntpTimeUtility::GetMessageFormat
    
  9. Then compile the nntp.dll again (and delete the original dll before compiling (del nntp.dll)):
    ilasm /dll nntp.il /resource=nntp.res
  10. Now you can copy the patched nntp.dll into the original directory (be sure, the application is not running).

Now it looks better:

That’s all! Happy NntpBridging ๐Ÿ˜‰

3 thoughts on “Forums NntpBridge and DateTime

Leave a Reply

Your email address will not be published. Required fields are marked *

Captcha *