2017-10-18 228 views
1

我在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

回答

相關問題