XamlParseException Недопустимый URI: не удалось определить формат URI - PullRequest
0 голосов
/ 23 февраля 2011

Я получаю это исключение в своем приложении WPF на одном конкретном ПК, на полдюжине других оно работает нормально.Вот полный след исключения:

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)

Ответы [ 2 ]

1 голос
/ 23 февраля 2011

Похоже, у него возникла проблема:

---> 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 голосов
/ 29 октября 2015

Проблема связана с запутанной переменной среды 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).

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...