Home Dashboard Directory Help
Search

PreCreateDefaultFamilyCollection fails on application startup by Christo Zietsman


Status: 

Active


2
0
Sign in
to vote
Type: Bug
ID: 522003
Opened: 12/24/2009 12:13:21 AM
Access Restriction: Public
0
Workaround(s)
view
2
User(s) can reproduce this bug

Description

When trying to start up our application it fails and reports a stacktrace which starts with:

System.TypeInitializationException: The type initializer for 'System.Windows.Media.FontFamily' threw an exception. ---> System.TypeInitializationException: The type initializer for 'MS.Internal.FontCache.Util' threw an exception. ---> System.UriFormatException: Invalid URI: The format of the URI could not be determined.
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
at System.Uri..ctor(String uriString, UriKind uriKind)
at MS.Internal.FontCache.Util..cctor()
--- End of inner exception stack trace ---
at System.Windows.Media.FontFamily.PreCreateDefaultFamilyCollection()
at System.Windows.Media.FontFamily..cctor()
--- End of inner exception stack trace ---
at System.Windows.Media.Typeface..ctor(FontFamily fontFamily, FontStyle style, FontWeight weight, FontStretch stretch)
at MS.Internal.Text.DynamicPropertyReader.GetTypeface(DependencyObject element)
at MS.Internal.Text.TextProperties.InitCommon(DependencyObject target)
at MS.Internal.Text.TextProperties..ctor(FrameworkElement target, Boolean isTypographyDefaultValue)

I'll attach the full stacktrace to this feedback item.

We've had at least two users reporting almost exactly the same stacktrace when they try to run our application. I was able to infer that the first user was running on a Czech version of Windows, because their "Application Data" folder is spelt "Data aplikací". The second user is studying at Malta University. The user did not report their Windows version, but I'm guessing it is a local copy.

We've tested on a clean install of Windows XP SP2 (English) and .NET 3.5 SP1 which is not giving us this issue.

I've search on the internet and found that this might be caused due to an invalid font installed on the users' machine, but there is no mention of this on Connect.

Our application is based on WPF, but it seems that the second user is getting the problem after the application called MessageBox.Show.
Details
Sign in to post a comment.
Posted by Microsoft on 7/12/2012 at 10:14 PM
The WPF team has recently reviewed this issue and will not be addressing this issue as at this time the team is focusing on the bugs impacting the highest number of WPF developers. If you believe that this was resolved in error, please reactivate this bug with any necessary supporting details.
Posted by rusticdog on 8/30/2010 at 2:46 AM
We also had a user with the same issue, after getting them to rename their 'windir' entry in the Registry as mentioned, and recreating a new one as an 'Expandable String Value' with %SystemRoot% as the value it would work for them.

They were running XP SP3, but I could not speculate what might have caused the Registry entry to be set to a 'String Value'
Posted by Sisqués on 1/22/2010 at 12:56 AM
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
Name windir
Type REG_EXPAND_SZ
Data %SystemRoot%
Posted by Microsoft on 1/21/2010 at 12:16 PM
Hi Sisqués,
Could you please check the type of the "windir" registry key under
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
and make sure its REG_EXPAND_SZ.
Posted by Sisqués on 1/21/2010 at 3:05 AM
I have the same problem. I have a spanish XP SP3 and my exception is:
No se controló System.TypeInitializationException
Message="Se produjo una excepción en el inicializador de tipo de 'System.Windows.Media.FontFamily'."
Source="PresentationCore"
TypeName="System.Windows.Media.FontFamily"
StackTrace:
     en System.Windows.Media.Typeface..ctor(FontFamily fontFamily, FontStyle style, FontWeight weight, FontStretch stretch)
     en MS.Internal.Text.DynamicPropertyReader.GetTypeface(DependencyObject element)
     en MS.Internal.Text.TextProperties.InitCommon(DependencyObject target)
     en MS.Internal.Text.TextProperties..ctor(FrameworkElement target, Boolean isTypographyDefaultValue)
     en System.Windows.Controls.TextBlock.GetLineProperties()
     en System.Windows.Controls.TextBlock.EnsureTextBlockCache()
     en System.Windows.Controls.TextBlock.MeasureOverride(Size constraint)
     en System.Windows.FrameworkElement.MeasureCore(Size availableSize)
     en System.Windows.UIElement.Measure(Size availableSize)
     en MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
     en System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
     en System.Windows.FrameworkElement.MeasureCore(Size availableSize)
     en System.Windows.UIElement.Measure(Size availableSize)
     en Microsoft.Windows.Themes.ClassicBorderDecorator.MeasureOverride(Size availableSize)
     en System.Windows.FrameworkElement.MeasureCore(Size availableSize)
     en System.Windows.UIElement.Measure(Size availableSize)
     en System.Windows.Controls.Control.MeasureOverride(Size constraint)
     en System.Windows.FrameworkElement.MeasureCore(Size availableSize)
     en System.Windows.UIElement.Measure(Size availableSize)
     en System.Windows.Controls.StackPanel.MeasureOverride(Size constraint)
     en System.Windows.FrameworkElement.MeasureCore(Size availableSize)
     en System.Windows.UIElement.Measure(Size availableSize)
     en System.Windows.Controls.StackPanel.MeasureOverride(Size constraint)
     en System.Windows.FrameworkElement.MeasureCore(Size availableSize)
     en System.Windows.UIElement.Measure(Size availableSize)
     en System.Windows.Controls.Grid.MeasureOverride(Size constraint)
     en System.Windows.FrameworkElement.MeasureCore(Size availableSize)
     en System.Windows.UIElement.Measure(Size availableSize)
     en MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
     en System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
     en System.Windows.FrameworkElement.MeasureCore(Size availableSize)
     en System.Windows.UIElement.Measure(Size availableSize)
     en System.Windows.Controls.Decorator.MeasureOverride(Size constraint)
     en System.Windows.Documents.AdornerDecorator.MeasureOverride(Size constraint)
     en System.Windows.FrameworkElement.MeasureCore(Size availableSize)
     en System.Windows.UIElement.Measure(Size availableSize)
     en System.Windows.Controls.Border.MeasureOverride(Size constraint)
     en System.Windows.FrameworkElement.MeasureCore(Size availableSize)
     en System.Windows.UIElement.Measure(Size availableSize)
     en System.Windows.Window.MeasureOverrideHelper(Size constraint)
     en System.Windows.Window.MeasureOverride(Size availableSize)
     en System.Windows.FrameworkElement.MeasureCore(Size availableSize)
     en System.Windows.UIElement.Measure(Size availableSize)
     en System.Windows.Interop.HwndSource.SetLayoutSize()
     en System.Windows.Interop.HwndSource.set_RootVisualInternal(Visual value)
     en System.Windows.Interop.HwndSource.set_RootVisual(Visual value)
     en System.Windows.Window.SetRootVisual()
     en System.Windows.Window.SetupInitialState(Double requestedTop, Double requestedLeft, Double requestedWidth, Double requestedHeight)
     en System.Windows.Window.CreateSourceWindowImpl()
     en System.Windows.Window.SafeCreateWindow()
     en System.Windows.Window.ShowHelper(Object booleanBox)
     en System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
     en System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
     en System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
     en System.Windows.Threading.DispatcherOperation.InvokeImpl()
     en System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
     en System.Threading.ExecutionContext.runTryCode(Object userData)
     en System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
     en System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
     en System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
     en System.Windows.Threading.DispatcherOperation.Invoke()
     en System.Windows.Threading.Dispatcher.ProcessQueue()
     en System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
     en MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
     en MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
     en System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
     en System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
     en System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
     en System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
     en System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
     en MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
     en MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
     en System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
     en System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
     en System.Windows.Threading.Dispatcher.Run()
     en System.Windows.Application.RunDispatcher(Object ignore)
     en System.Windows.Application.RunInternal(Window window)
     en System.Windows.Application.Run(Window window)
     en System.Windows.Application.Run()
     en SIGAManager.Application.Main() en C:\proyectos\siga\ClienteSigaManager\SIGAManager\obj\Debug\Application.g.vb:línea 62
     en System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
     en System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
     en Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
     en System.Threading.ThreadHelper.ThreadStart_Context(Object state)
     en System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
     en System.Threading.ThreadHelper.ThreadStart()
InnerException: System.TypeInitializationException
     Message="Se produjo una excepción en el inicializador de tipo de 'MS.Internal.FontCache.Util'."
     Source="PresentationCore"
     TypeName="MS.Internal.FontCache.Util"
     StackTrace:
            en System.Windows.Media.FontFamily.PreCreateDefaultFamilyCollection()
            en System.Windows.Media.FontFamily..cctor()
     InnerException: System.UriFormatException
            Message="URI no válido: no se puede determinar el formato del URI."
            Source="System"
            StackTrace:
                 en System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
                 en System.Uri..ctor(String uriString, UriKind uriKind)
                 en MS.Internal.FontCache.Util..cctor()
            InnerException:
Posted by Christo Zietsman on 1/15/2010 at 12:24 AM
Hi,

We'll ask the client with the problematic PC to check the registry entry. If the registry entry has an incorrect type, then it is still unclear to us how this problem occurred, since we're not touching the registry. It must have been there before the client tried to install our application.

We hope the root cause of the problem will be found.
Thanks
Posted by Microsoft on 1/14/2010 at 1:40 PM
Hi,

Could you please check the type of the "windir" registry key under
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
and make sure its REG_EXPAND_SZ.
If on the problematic PC you found it to be REG_SZ then this explains the problem.
http://support.microsoft.com/kb/104011

Thanks
Posted by Microsoft on 1/13/2010 at 1:03 PM
Thank you for your replies. We will look into this. Meanwhile if you change the value in %windir% to be the path to the windows folder ("C:\Windows" for example) PreCreateDefaultFamilyCollection should pass.
Posted by Christo Zietsman on 1/13/2010 at 5:20 AM
Our user also confirmed that they get:

C:\>echo %windir%
%SystemRoot%

on the problematic machine.

Posted by LAN_Selot on 1/5/2010 at 7:01 AM
Edit: %SystemDir% is %SystemRoot%
Posted by LAN_Selot on 1/5/2010 at 7:00 AM
A clarification:

If I go to My Computer -> Properties ... Environment Variables and I select windir and click Edit, in the TextBox I get %SystemDir%.

However, if I write a console application and there I use System.Environment.GetEnvironmentVariable("WINDIR"), I get different results on a problematic and a non-problematic PC. On the machine that reproduces the problem, I get %SystemRoot%. On the machine that is O.K. I get C:\Windows.
Posted by LAN_Selot on 1/5/2010 at 6:05 AM
It's %SystemRoot%. I suppose it should be C:\Windows?
Posted by Microsoft on 1/4/2010 at 1:33 PM
Thank you for reporting this issue.
Could you please let us know the value of the WinDir environment variable on a machine that repros this problem?
Posted by LAN_Selot on 12/28/2009 at 7:29 AM
Hello,

I also encountered this problem on a client's PC. It was running .NET 3.5 SP1 on Windows XP SP3. It seemed to me that no WPF application that displayed any text would run, even a very simple one. This is the exception, logged by our product:

<LogEntry>
    <DateTime>22.12.2009 17:08:51</DateTime>
    <UserOSVersion>Microsoft Windows XP Professional(Win32NT 5.1.2600.196608)</UserOSVersion>
    <BuildVersion>1.1.4 (27414)</BuildVersion>
    <Message>Application.xaml.vb</Message>
    <Exception>System.Windows.Markup.XamlParseException: Failed object initialization (ISupportInitialize.EndInit). The type initializer for 'System.Windows.Media.FontFamily' threw an exception. Error at object 'Microinvest.InvoicePro.Controls.AnimatedExpanderControl' in markup file 'InvoicePro;component/mainwindow.xaml'. ---> System.TypeInitializationException: The type initializer for 'System.Windows.Media.FontFamily' threw an exception. ---> System.TypeInitializationException: The type initializer for 'MS.Internal.FontCache.Util' threw an exception. ---> System.UriFormatException: Invalid URI: The format of the URI could not be determined.
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
at System.Uri..ctor(String uriString, UriKind uriKind)
at MS.Internal.FontCache.Util..cctor()
--- End of inner exception stack trace ---
at System.Windows.Media.FontFamily.PreCreateDefaultFamilyCollection()
at System.Windows.Media.FontFamily..cctor()
--- End of inner exception stack trace ---
at System.Windows.Media.Typeface..ctor(FontFamily fontFamily, FontStyle style, FontWeight weight, FontStretch stretch)
at MS.Internal.Text.DynamicPropertyReader.GetTypeface(DependencyObject element)
at MS.Internal.Text.TextProperties.InitCommon(DependencyObject target)
at MS.Internal.Text.TextProperties..ctor(FrameworkElement target, Boolean isTypographyDefaultValue)
at System.Windows.Controls.TextBlock.GetLineProperties()
at System.Windows.Controls.TextBlock.EnsureTextBlockCache()
at System.Windows.Controls.TextBlock.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Border.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.DockPanel.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Control.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Border.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.Control.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at System.Windows.Controls.StackPanel.MeasureOverride(Size constraint)
at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
at System.Windows.UIElement.Measure(Size availableSize)
at Microinvest.InvoicePro.Controls.AnimatedExpanderControl.ContentLengthPropertyCoerceValue(DependencyObject d, Object baseValue)
at System.Windows.DependencyObject.ProcessCoerceValue(DependencyProperty dp, PropertyMetadata metadata, EntryIndex& entryIndex, Int32& targetIndex, EffectiveValueEntry& newEntry, EffectiveValueEntry& oldEntry, Object& oldValue, Object baseValue, CoerceValueCallback coerceValueCallback, Boolean coerceWithDeferredReference, Boolean skipBaseValueChecks)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, OperationType operationType)
at System.Windows.DependencyObject.CoerceValue(DependencyProperty dp)
at Microinvest.InvoicePro.Controls.AnimatedExpanderControl.OnApplyTemplate()
at System.Windows.FrameworkElement.ApplyTemplate()
at Microinvest.InvoicePro.Controls.AnimatedExpanderControl.AnimatiedExpanderControl_Initialized(Object sender, EventArgs e)
at System.Windows.FrameworkElement.RaiseInitialized(EventPrivateKey key, EventArgs e)
at System.Windows.FrameworkElement.OnInitialized(EventArgs e)
at System.Windows.FrameworkElement.TryFireInitialized()
at System.Windows.FrameworkElement.EndInit()
at System.Windows.Markup.BamlRecordReader.ElementEndInit(Object& element)
--- End of inner exception stack trace ---
at System.Windows.Markup.XamlParseException.ThrowException(String message, Exception innerException, Int32 lineNumber, Int32 linePosition, Uri baseUri, XamlObjectIds currentXamlObjectIds, XamlObjectIds contextXamlObjectIds, Type objectType)
at System.Windows.Markup.XamlParseException.ThrowException(ParserContext parserContext, Int32 lineNumber, Int32 linePosition, String message, Exception innerException)
at System.Windows.Markup.BamlRecordReader.ThrowExceptionWithLine(String message, Exception innerException)
at System.Windows.Markup.BamlRecordReader.ElementEndInit(Object& element)
at System.Windows.Markup.BamlRecordReader.ReadElementEndRecord(Boolean fromNestedBamlRecordReader)
at System.Windows.Markup.BamlRecordReader.ReadRecord(BamlRecord bamlRecord)
at System.Windows.Markup.BamlRecordReader.Read(Boolean singleRecord)
at System.Windows.Markup.TreeBuilderBamlTranslator.ParseFragment()
at System.Windows.Markup.TreeBuilder.Parse()
at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
at Microinvest.InvoicePro.View.MainWindow.InitializeComponent()
at Microinvest.InvoicePro.View.MainWindow..ctor()
at Microinvest.InvoicePro.Application.OnStartup(StartupEventArgs e)
at System.Windows.Application.<.ctor>b__0(Object unused)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at Microinvest.InvoicePro.Application.Main()</Exception>
    <Type>Error</Type>
</LogEntry>
Posted by Microsoft on 12/25/2009 at 12:57 AM
Thank you for your feedback, We are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.