2011-02-22 25 views
0

特定のPCのWPFアプリケーションでこの例外が発生しました。ここでは完全な例外トレースは次のとおりです。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-up)。私はこの質問が古いことを知っていますが、もう1つはより良い回答を持っています –

答えて

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

0

この問題は、WinDir環境変数が混乱し、内部MicrosoftクラスFontCache.Utilの静的イニシャライザで使用されているために発生します。これは、ここに記載されているように、非常に長いPATH環境変数によって引き起こされる可能性があります。https://superuser.com/questions/237268/missing-environment-variables-in-windows-7

(FontCache.Util:http://referencesource.microsoft.com/#PresentationCore/Core/CSharp/MS/Internal/FontCache/FontCacheUtil.cs)。

関連する問題