c# - .NET 应用程序无法启动和接收 XamlParseException

我编写了一个可以安装和在我的开发 PC ( 窗口 7 ) 上工作的应用。

  • 开发环境:窗口 7 VS2010 WPF C# 与 .NET 4和 .NET 3.5安装

在其他客户端计算机( XP SP3,2和 1 ) 上,安装没有错误,但无法启动。 在任务管理器中,我可以看到应用程序在关闭内存之前临时占用内存。

我通过以下方式确保. NET 3.5在我的开发PC和各种客户端XP机器之间的一致性:

  • 应用程序目标 .NET 3.5(或 3.5 客户概要 )
  • 使用VS2010安装程序进行部署: 启动条件下目标为 .NET 3.5
  • 在应用程序和安装程序项目调试期间,没有关于. NET 兼容性的任何错误

获取以下警告:

 ¬º˛¿‡–Õ: ¥ÌŒÛ
 ¬º˛¿¥‘¥:. NET Runtime
 ¬º˛÷÷¿‡: Œfi
 ¬º˛ ID: 1026
»’∆⁄: 2011-10-18
 ¬º˛: 15:18:32
"√ªß: N/A
º∆À„ª˙: WWW-9DB69D5A3AF
√Ë ˆ:
Application: Foo.exe
Framework Version: v4.0.30319
Description:""⁄Œ¥æ≠¥¶¿Ìµƒ"Ï≥££¨Ω¯≥Ã÷’÷π°£
"Ï≥£–≈œ¢: System.Windows.Markup.XamlParseException
∂—’ª:
 ‘⁄ System.Windows.Markup.XamlReader.RewrapException(System.Exception, System.Xaml.IXamlLineInfo, System.Uri)
 ‘⁄ System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader, System.Xaml.IXamlObjectWriterFactory, Boolean, System.Object, System.Xaml.XamlObjectWriterSettings, System.Uri)
 ‘⁄ System.Windows.Markup.WpfXamlLoader.LoadBaml(System.Xaml.XamlReader, Boolean, System.Object, System.Xaml.Permissions.XamlAccessLevel, System.Uri)
 ‘⁄ System.Windows.Markup.XamlReader.LoadBaml(System.IO.Stream, System.Windows.Markup.ParserContext, System.Object, Boolean)
 ‘⁄ System.Windows.Application.LoadBamlStreamWithSyncInfo(System.IO.Stream, System.Windows.Markup.ParserContext)
 ‘⁄ System.Windows.Application.LoadComponent(System.Uri, Boolean)
 ‘⁄ System.Windows.Application.DoStartup()
 ‘⁄ System.Windows.Application.<.ctor>b__1(System.Object)
 ‘⁄ System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
 ‘⁄ MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
 ‘⁄ System.Windows.Threading.DispatcherOperation.InvokeImpl()
 ‘⁄ System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object)
 ‘⁄ System.Threading.ExecutionContext.runTryCode(System.Object)
 ‘⁄ System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object)
 ‘⁄ System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
 ‘⁄ System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
 ‘⁄ System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
 ‘⁄ System.Windows.Threading.DispatcherOperation.Invoke()
 ‘⁄ System.Windows.Threading.Dispatcher.ProcessQueue()
 ‘⁄ System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
 ‘⁄ MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
 ‘⁄ MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
 ‘⁄ System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
 ‘⁄ MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
 ‘⁄ System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
 ‘⁄ MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
 ‘⁄ MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
 ‘⁄ System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
 ‘⁄ System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame)
 ‘⁄ System.Windows.Threading.Dispatcher.Run()
 ‘⁄ System.Windows.Application.RunDispatcher(System.Object)
 ‘⁄ System.Windows.Application.RunInternal(System.Windows.Window)
 ‘⁄ System.Windows.Application.Run(System.Windows.Window)
 ‘⁄ System.Windows.Application.Run()
 ‘⁄ FooSoftware.App.Main()
"–πÿ∏¸∂‡–≈œ¢£¨«Î≤Œ‘ƒ‘⁄ http://go.microsoft.com/fwlink/events.asp µƒ∞Ô÷˙∫Õ÷ß≥÷÷––ƒ°£

有一个XamlParseException导致我的应用无法在XP窗口机器上启动。 到底是怎么回事?

时间:17年05月07日原作者:KMC 共18个回答

0 0

XamlParseException 是在应用程序启动时出现问题时发生的一般性错误。 我建议你修改你的应用程序启动代码来跟踪到底发生了什么和得到什么,不仅是 XamlParseException,还应该有内部异常来帮助你确定问题的root 。 以下是一个示例:

namespace WpfApplication1
{
///<summary>
///Interaction logic for App.xaml
///</summary>
 public partial class App : Application
 {
 protected override void OnStartup(StartupEventArgs e)
 {
//hook on error before app really starts
 AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
 base.OnStartup(e);
 }
 void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
//put your tracing or logging code here (I put a message box as an example)
 MessageBox.Show(e.ExceptionObject.ToString());
 }
 }
}
发布了11 篇原创文章 · 获赞 16 · 访问量 9万+

猜你喜欢

转载自blog.csdn.net/orange2211/article/details/80233923