A trio of self-explanatory exceptions

Good: there’s a Visual Studio extension that allows you to bind F1 (or another shortcut) to “open a new browser and search for the currently highlighted text”.  Saves me at least 24 keystrokes per day, or over 100k keystrokes before I get to retire.

Bad: sometimes you get an exception that looks extremely self-explanatory, but the obvious solution, nor any of the search result web pages seems to solve your issue.

Even worse: had three of those in one day.  I thought I would save someone else some trouble some day, and post about these three ‘self-explanatory’ exceptions, and explain what the description really meant to me.

OutOfMemoryException: Out of memory.

[OutOfMemoryException: Out of memory.]
   System.Drawing.Graphics.FromHdcInternal(IntPtr hdc) +1151157
   System.Drawing.Font.ToLogFont(Object logFont) +145
   System.Drawing.Font.ToHfont() +98
   Telerik.Reporting.Pdf.Fonts.TrueType.FontReader.GetFontData(Font font, Boolean& isTTC) +101

What is seems to mean: “You are out of memory.  Consider scaling out.”

What it really meant in my case: “You are trying to run a Telerik report or another operation that requires GDI+ from an Azure Web Site.  Azure Web Sites do not support GDI+. Consider deploying to an Azure Cloud Service instead, or… Ah, screw it, this exception message is too long, let me just throw you an out of memory exception instead.”

What I did: deployed to an Azure Cloud Service.  Sent the bill to Telerik.  No response yet.

Unable to find any implementation of the contract: ‘Microsoft.LightSwitch.BaseServices.Logging.Internal.ILoggingService’

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ComponentModel.Composition.CompositionException: The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.

1) Unable to find any implementation of the contract: 'Microsoft.LightSwitch.BaseServices.Logging.Internal.ILoggingService'

What is seems to mean: “Your IOC container, MEF, is missing an implementation of the ILoggingService.”

What it really meant in my case: “You tried to instantiate a ServerApplicationContext, but something went wrong.  Whatever went wrong will be logged, let me just get a logger from the MEF container that is created when you instantiate a ServerApplicationContext.  Oooo crap”.

What I did: found that some of my ServerApplicationContexts wasn’t properly being disposed of.  Always wrap your IDisposables in a using statement.

System.Security.SecurityException: Dialogs must be user-initiated

What is seems to mean: “You are trying to show a Print/Save/Open dialog from a sandboxed Silverlight application, but the user asked for no such thing.”

What it really meant in my case: “You are trying to show a Print/Save/Open dialog from a sandboxed Silverlight application, and the user did just click a Print/Save/Open button.  However, somewhere deeply buried in MSDN documentation it says that between the user instantiated event and the point where you show a dialog, there can only be a very limited amount of time.  The length of this time limit isn’t specified in an absolute number of milliseconds, but as ‘the number of milliseconds you really need, minus 5‘.”

What I did: removed all breakpoints, and split up the processing of the report and the actual printing in a two-step process.  This way, when the report is fully rendered, the user has to click a button “ok well print it then” which only invokes the actual print dialog.

Your turn, Dr. Watson.

11 thoughts on “A trio of self-explanatory exceptions

  1. Pingback: Unit Testing Intro - The Daily Six Pack: January 16, 2014

  2. Pingback: LightSwitch Community & Content Rollup–January 2014 - Beth Massi - Sharing the goodness - Site Home - MSDN Blogs

  3. I’m curious to find out what blog platform you are working with?
    I’m having some minor security issues with my latest site and
    I would like to find something more secure. Do you have any recommendations?

  4. Hello there, You’ve done a fantastic job. I’ll certainly digg it and
    personally suggest to my friends. I’m confident
    they’ll be benefited from this web site.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s