我目前正在开发一个C# WPF项目,该项目使用MySQL.Data和System.Data.Sqlite dll以及其他一些dll。
该项目是一个.Net 4项目,在我的开发机器上运行没有问题。我创建了一个MSI安装程序包,当我添加可执行文件时,Visual Studio会解决依赖关系并添加所需的DLL到EXE中。
当我在我的开发机器上运行安装程序时,一切都正常。然而,当我将安装程序复制到安装了.Net Framework 3.5和.Net Framework 4的空白虚拟机上时,安装程序显示一切都已成功安装,当我查看程序文件夹时,所有的DLL也都在那里,但当我尝试运行软件时,软件无法加载,并在事件查看器中显示了.Net Runtime错误。
错误信息如下:
应用程序:MySQLBackup.exe 框架版本:v4.0.30319 描述:由于未处理的异常,该进程已终止。 异常信息:System.IO.FileLoadException 堆栈:at MySQLBackup.App.Application_Startup(System.Object, System.Windows.StartupEventArgs) at System.Windows.Application.OnStartup(System.Windows.StartupEventArgs) at System.Windows.Application.<.ctor>b__1(System.Object) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32) at MS.Internal.Threading.ExceptionFilterHelper.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.runTryCode(System.Object) at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object) at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) 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 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 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate) at System.Windows.Threading.Dispatcher.InvokeImpl(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.Threading.Dispatcher.Run() 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 MySQLBackup.App.Main()
错误信息并不能帮助我找出问题所在,因此我在应用程序启动事件中添加了try catch语句,但是异常从未被捕获。我还在
如何找出问题并解决它?
该项目是一个.Net 4项目,在我的开发机器上运行没有问题。我创建了一个MSI安装程序包,当我添加可执行文件时,Visual Studio会解决依赖关系并添加所需的DLL到EXE中。
当我在我的开发机器上运行安装程序时,一切都正常。然而,当我将安装程序复制到安装了.Net Framework 3.5和.Net Framework 4的空白虚拟机上时,安装程序显示一切都已成功安装,当我查看程序文件夹时,所有的DLL也都在那里,但当我尝试运行软件时,软件无法加载,并在事件查看器中显示了.Net Runtime错误。
错误信息如下:
应用程序:MySQLBackup.exe 框架版本:v4.0.30319 描述:由于未处理的异常,该进程已终止。 异常信息:System.IO.FileLoadException 堆栈:at MySQLBackup.App.Application_Startup(System.Object, System.Windows.StartupEventArgs) at System.Windows.Application.OnStartup(System.Windows.StartupEventArgs) at System.Windows.Application.<.ctor>b__1(System.Object) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32) at MS.Internal.Threading.ExceptionFilterHelper.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.runTryCode(System.Object) at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object) at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) 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 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 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate) at System.Windows.Threading.Dispatcher.InvokeImpl(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.Threading.Dispatcher.Run() 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 MySQLBackup.App.Main()
错误信息并不能帮助我找出问题所在,因此我在应用程序启动事件中添加了try catch语句,但是异常从未被捕获。我还在
InitialiseComponent()
方法周围添加了try catch,这个方法在第一个应该加载的对话框窗口上执行,但是再次没有捕获到异常,因此我无法看到导致错误的原因。如何找出问题并解决它?