TypeInitializationException - The type initializer for 'System.Windows.Window' threw an exception

edited November 2012
For anyone else getting this error, check your log file in %localappdata%\linqpad\logs. If the exception contains the following details:
INNER: TypeInitializationException

The type initializer for 'System.Windows.FrameworkElement' threw an exception.

at System.Windows.Window..cctor()
INNER: TypeInitializationException

The type initializer for 'System.Windows.Documents.TextElement' threw an exception.

at System.Windows.FrameworkElement..cctor()
INNER: TypeInitializationException

The type initializer for 'MS.Internal.FontCache.Util' threw an exception.

at MS.Internal.FontCache.Util.get_Dpi()
at System.Windows.SystemFonts.ConvertFontHeight(Int32 height)
at System.Windows.Documents.TextElement..cctor()
then check your operating system path variable:

Environment.ExpandEnvironmentVariables("%path%")

An invalid environmental path can cause this exception when calling WPF components such as the IQ driver or NuGet integration window. In particular, bear in mind that the path is limited to ~2K characters in Windows 7 and installing too much software can cause the path variable to get truncated!
Sign In or Register to comment.