我在visual studio 2010中编写了一个WPF C#应用程序,但它无法在我的Windows 10机器上启动。我在一台不同的计算机上遇到了这个问题,安装Direct X 9修复了我的问题,这次没有。我尝试过兼容模式,没有运气。我也尝试在程序的初始化中添加一些异常处理,就像我在这里阅读其他一些帖子一样,但是当我启动应用程序时,它似乎甚至没有达到这一点。这就是我为此所做的,我根本没有弹出窗口:
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());
}
当我查看事件查看器时,我收到两个错误:应用程序错误:
错误应用程序名称:BuildingManagerWPF.exe,版本:1.0.0.0, 时间戳:0x59e6d248错误模块名称:KERNELBASE.dll,版本: 10.0.14393.479,时间戳:0x58256d37异常代码:0xe0434352故障偏移量:0x000da832故障进程id:0x218故障 应用程序启动时间:0x01d347c8387ca8a0错误应用程序路径: C:\ Users \用户lattepanda \桌面\建筑\ BuildingManagerWPF.exe 错误模块路径:C:\ WINDOWS \ System32 \ KERNELBASE.dll报告ID: 08f61ca3-5455-4f5c-98df-1195f203d482错误包全名: 错误的包相关应用程序ID:
.NET运行时错误:
应用程序:BuildingManagerWPF.exe Framework版本:v4.0.30319 描述:由于未处理的异常,进程终止。 异常信息:System.IO.FileNotFoundException at BuildingManagerWPF.MainWindow..ctor()
异常信息: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的) 在 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, Int.Ptr,布尔ByRef)在MS.Win32.HwndWrapper.WndProc(IntPtr, Int32,IntPtr,IntPtr,Boolean ByRef)at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)at 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)
在 MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame) 在 System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame) 在System.Windows.Application.RunDispatcher(System.Object)处 System.Windows.Application.RunInternal(System.Windows.Window)at System.Windows.Application.Run(System.Windows.Window)at BuildingManagerWPF.App.Main()中的System.Windows.Application.Run()
答案 0 :(得分:0)
如果您的Visual Studio 2010未更新到SP1,那么请尝试开始: Update for Microsoft Visual Studio 2010 Service Pack 1 (KB2736182)
但也许你应该考虑将视觉工作室版本更新为新版本? Visual Studio Downloads
祝你好运!