Wednesday 14 March 2012

WPF program crashes when printing

I had a customer this week let me know that he was unable to print from our Payslips for HMRC PAYE Tools program.

After a long time spent debugging, it transpires that the computer had a problem in the registry, where a font was incorrectly installed.

In his case, it was this font: MT Extra (TrueType)
and it was installed here on his XP machine:
C:\Program Files\Common Files\Microsoft Shared\Equation\mtextra.ttf

We deleted the entry, and managed to print to the XPS driver, but printing to the printer itself still didn’t work.  Maybe it requires a reboot?  Still looking into that one.

And we’re not the first to see this either.  Here are a couple more reports in the wild:

Bradley Grainger's 2009 blog entry

and this one from 2011 by Divya N Singh

2 comments:

  1. Further investigation into this dll C:\Windows\Microsoft.NET\assembly\GAC_32\System.Printing\v4.0_4.0.0.0__31bf3856ad364e35\System.Printing.dll shows the implementation of BuildFontList should be able to handle fonts with absolute addresses.

    But, if for some reason IsAbsoluteUri were to return false, it would indeed crash as seen.

    Now, what could be causing that to return false? A check against m_Syntax == null, which could imply that it was the parsing that went wrong.

    ReplyDelete
  2. Wrote a test program, based on the implementation in System.Printing.Dll (which is very similar to the one Divya N Singh wrote), and found the following.

    Something had appended extra values past the null character to the Arial, Arial Bold, Comic Sans, and Comic Sans Bold fonts. It looks like what Raymond Chen described here, only I think there were extra characters past the null.
    http://blogs.msdn.com/b/oldnewthing/archive/2004/08/24/219444.aspx

    ReplyDelete