2011-02-22 55 views
0

我在一臺特定PC上的WPF應用程序中發現此異常,在其他六臺PC上運行正常。以下是完整的異常跟蹤:XamlParseException URI無效:無法確定URI的格式

System.Windows.Markup.XamlParseException: The type initializer for 'System.Windows.Window' threw an exception. 
---> System.TypeInitializationException: The type initializer for 'System.Windows.FrameworkElement' threw an exception. 
---> System.TypeInitializationException: The type initializer for 'System.Windows.Documents.TextElement' 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 MS.Internal.FontCache.Util.get_Dpi() 
    at System.Windows.SystemFonts.ConvertFontHeight(Int32 height) 
    at System.Windows.Documents.TextElement..cctor() 

    --- End of inner exception stack trace --- 

    at System.Windows.FrameworkElement..cctor() 

    --- End of inner exception stack trace --- 

    at System.Windows.Window..cctor() 

    --- End of inner exception stack trace --- 

    at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri) 
    at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri) 
    at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri) 
    at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream) 
    at System.Windows.Application.LoadBamlStreamWithSyncInfo(Stream stream, ParserContext pc) 
    at System.Windows.Application.LoadComponent(Uri resourceLocator, Boolean bSkipJournaledProperties) 
    at System.Windows.Application.DoStartup() 
    at System.Windows.Application.<.ctor>b__1(Object unused) 
    at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) 
    at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler) 
+0

[WPF窗口在啓動時拋出TypeInitializationException]的可能重複(http://stackoverflow.com/questions/10094197/wpf-window-throws-typeinitializationexception-at-startup)。我知道這個問題比較老,但另一個有更好的答案 –

回答

1

它看起來像它在這一點上有一個問題:

---> 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. 

看到,這個問題是不是機器之間是一致的,並有字體的提及,這可能您是否引用了未安裝在此特定機器上的字體?

+0

該應用程序使用默認的WPF字體「Segoe UI」。我相信它應該選擇一些替代字體,如果沒有安裝?無論如何,我認爲你在正確的軌道上。謝謝。 – user380689