WPF桌面应用程序无法在Windows 10中启动

问题描述:

我在Visual Studio 2010中编写了WPF C#应用程序,但它不会在Windows 10计算机上启动。我在一个不同的计算机上遇到了这个问题,安装Direct X 9解决了我的问题,但这次并没有解决。我尝试了兼容模式,没有运气。我也尝试在程序的初始化中添加一些异常处理,就像我在这里阅读过的其他帖子一样,但是当我启动应用程序时,它似乎甚至没有做到这一点。这是我做的是,我没有得到任何弹出窗口都:WPF桌面应用程序无法在Windows 10中启动

 protected override void OnInitialized(EventArgs e) 
    { 
     MessageBox.Show("OnInitialized"); 
     // hook on error before app really starts 
     base.OnInitialized(e); 
    } 

    public override void BeginInit() 
    { 
     MessageBox.Show("BeginInit"); 
     AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); 
     Application.Current.DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(Current_DispatcherUnhandledException); 

     base.BeginInit(); 
    } 

    protected override void OnSourceInitialized(EventArgs e) 
    { 
     MessageBox.Show("OnSourceInitialized"); 

     base.OnSourceInitialized(e); 
    } 

    void Current_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) 
    { 
     MessageBox.Show(e.Exception.Message); 
    } 

    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()); 
    } 

当我看到在事件查看器,我得到两个错误,一个应用程序错误:

Faulting application name: BuildingManagerWPF.exe, version: 1.0.0.0, time stamp: 0x59e6d248 Faulting module name: KERNELBASE.dll, version: 10.0.14393.479, time stamp: 0x58256d37 Exception code: 0xe0434352 Fault offset: 0x000da832 Faulting process id: 0x218 Faulting application start time: 0x01d347c8387ca8a0 Faulting application path: C:\Users\lattepanda\Desktop\Building\BuildingManagerWPF.exe Faulting module path: C:\WINDOWS\System32\KERNELBASE.dll Report Id: 08f61ca3-5455-4f5c-98df-1195f203d482 Faulting package full name: Faulting package-relative application ID:

而一个.NET运行时错误:

Application: BuildingManagerWPF.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.IO.FileNotFoundException at BuildingManagerWPF.MainWindow..ctor()

Exception Info: System.Windows.Markup.XamlParseException 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_0(System.Object) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32) at System.Windows.Threading.ExceptionWrapper.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.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) 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 MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, 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 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate) at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(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.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 BuildingManagerWPF.App.Main()

+0

BuildingManagerWPF? – Fredrik

+0

你的'MainWindow'的构造函数是什么? – dymanoid

+0

在我运行应用程序的机器上投掷了视觉工作室,结果发现有一些问题引用了sqlserverCE。我相信任何人都可以猜到。 – Vandel212

如果您的Visual Studio 2010中不会更新到SP1,那么请尝试以开始: Update for Microsoft Visual Studio 2010 Service Pack 1 (KB2736182)

但也许你应该考虑将视觉工作室版本更新为更新的版本......? Visual Studio Downloads

祝你好运!

+2

您确定这是错误原因吗?如果没有,你不应该把它作为答案。 – dymanoid