我目前正在开发一个 C# WPF 项目,该项目使用 MySQL.Data 和 System.Data.Sqlite dll 以及其他几个。
该项目是一个 .Net 4 项目,在我的开发机器上运行没有问题。我创建了一个 MSI 安装程序包,当我添加可执行文件时,Visual Studio 会计算出依赖关系,并使用 EXE 添加所需的 DLL。
当我在开发计算机上运行安装程序时,一切正常。但是,当我将安装程序复制到安装了 .Net Framework 3.5 和 .Net Framework 4 的空白虚拟机时,安装程序表示一切已成功安装,当我查看程序文件文件夹时,所有 DLL 也都在那里,但是当我尝试运行该软件,但该软件未加载,并且事件查看器中显示 .Net 运行时错误。
错误如下
应用程序:MySQLBackup.exe 框架版本:v4.0.30319
描述:由于未处理的异常,进程被终止。
异常信息:System.IO.FileLoadException 堆栈:位于
MySQLBackup.App.Application_Startup(System.Object,
System.Windows.StartupEventArgs)位于
System.Windows.Application.OnStartup(System.Windows.StartupEventArgs)
在 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、布尔值)位于
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,布尔 ByRef)在 MS.Win32.HwndWrapper.WndProc(IntPtr,Int32,
IntPtr、IntPtr、布尔 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
通过参考)在
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)位于
MySQLBackup.App.Main() 处的 System.Windows.Application.Run()
错误消息并不能真正帮助我找出问题所在,因此在应用程序启动事件中我添加了 try catch 语句,但从未捕获异常。我还添加了 try catch 周围InitialiseComponent()
方法在应该加载的第一个对话窗口上执行,但再次捕获从未被捕获,所以我看不到导致错误的原因。
我怎样才能找出这个问题是什么并解决它?
How can I figure out what this problem is and fix it.
使用执行远程调试Visual Studio 远程调试器 http://www.microsoft.com/download/en/details.aspx?id=475.
本教程 http://msdn.microsoft.com/en-us/library/y7f5zaaa.aspx给出了如何使用它的想法。
一旦熟悉了 VS 远程调试,您将始终使用这个强大的工具在潜在的客户端环境上进行测试。
至于您的特定问题,您在 Application.Startup 事件处理程序中有一些代码尝试加载某些文件并失败。如果您自己无法找到问题根源,请在您的 App.xaml 中发布代码,以便我们进行分析。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)