Подтвердить что ты не робот

System.Windows.Markup.XamlParseException

Я написал приложение WPF, на моем compuyter он работает нормально. Теперь я пытаюсь развернуть приложение wpf на компьютере W7. И получить следующее исключение:

Description: The process was terminated due to an unhandled exception.
Exception Info: System.Windows.Markup.XamlParseException
Stack:
   at System.Windows.Markup.XamlReader.RewrapException(System.Exception, System.Xaml.IXamlLineInfo, System.Uri)
   at System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader, System.Xaml.IXamlObjectWriterFactory, Boolean, System.Object, System.Xaml.XamlObjectWriterSettings, System.Uri)
   at System.Windows.Markup.WpfXamlLoader.LoadBaml(System.Xaml.XamlReader, Boolean, System.Object, System.Xaml.Permissions.XamlAccessLevel, System.Uri)
   at System.Windows.Markup.XamlReader.LoadBaml(System.IO.Stream, System.Windows.Markup.ParserContext, System.Object, Boolean)
   at System.Windows.Application.LoadBamlStreamWithSyncInfo(System.IO.Stream, System.Windows.Markup.ParserContext)
   at System.Windows.Application.LoadComponent(System.Uri, Boolean)
   at System.Windows.Application.DoStartup()
   at System.Windows.Application.<.ctor>b__1(System.Object)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object)
   at System.Threading.ExecutionContext.runTryCode(System.Object)
   at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
   at System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame)
   at System.Windows.Threading.Dispatcher.Run()
   at System.Windows.Application.RunDispatcher(System.Object)
   at System.Windows.Application.RunInternal(System.Windows.Window)
   at System.Windows.Application.Run(System.Windows.Window)
   at System.Windows.Application.Run()
   at CAMXSimulator.App.Main()

Любая идея, что здесь не так?

Спасибо

4b9b3361

Ответ 1

Этот тип исключения является обычным явлением, когда некоторая часть конструктора главного окна или операций загрузки терпит неудачу. Если вы можете получить трассировку стека, посмотрите на внутреннее исключение, и вы, вероятно, найдете реальную проблему.

Ответ 2

У меня была эта проблема, потому что я показывал форму из конструктора Application. Эта форма использовала Style = "{StaticResource XYZ}". Этот статический ресурс был определен в файле XAML приложения.

Я решил проблему, показывая форму на более позднем этапе приложения, когда объект приложения был полностью сконструирован.

Ответ 3

У меня был тот же отчет об исключениях. Я мог бы решить эту проблему с помощью программы windbg.

  • загрузите версию windbg x86 (не x64).
  • откройте в нем файл .exe приложения (меню "Файл" → "Открыть exe" ).
  • запустите эти команды, чтобы увидеть реальное исключение:

После анализа я обнаружил, что в системе отсутствует сборка System.Net.Http.Formatting.

0:000> g
0:000> sxe clr
0:000> g
0:000> !loadby sos clr
0:000> !CLRStack
0:000> !PrintException

Exception type: System.IO.FileNotFoundException
Message: Could not load file or assembly 'System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
    InnerException: <none>

Ответ 4

Единственное, о чем я могу думать, это то, имеют ли обе коробки одну и ту же версию .NET на нем .NET 4 имеет некоторые новые функции (re-анализатор XAML), что 3.5 SP1 не имеет

Ответ 5

Я заметил подобное поведение при установке приложения ClickOnce на чистой машине. Я решил, установив требования приложения для установки как .Net 4, так и .Net 3.5.

Этого больше не было.

Ответ 6

Убедитесь, что вы создали правильную архитектуру x86 или x64 при запуске на целевой машине. Я столкнулся с той же проблемой, что и приложение, которое можно запустить на моем футбольном диске FAT32, однако это не удалось на другой машине с Windows 7 - 32bit (я знаю, что Windows 7 с 32-разрядным довольно странным) см. http://social.msdn.microsoft.com/Forums/vstudio/en-US/8f803f28-dfda-4be5-9e8d-f7d82db95961/c-wpf-systemwindowsmarkupxamlparseexception?forum=wpf