System.IO.FileLoadException在其他计算机上运行C#程序时出现异常

System.IO.FileLoadException在其他计算机上运行C#程序时出现异常,c#,wpf,fileloadexception,C#,Wpf,Fileloadexception,我目前正在从事一个C#WPF项目,该项目使用MySQL.Data和System.Data.Sqlite dll以及其他几个dll 该项目是一个.NET4项目,在我的开发机器上运行没有问题。我创建了一个MSI安装程序包,当我添加可执行文件时,VisualStudio会计算出依赖项并将所需的DLL与EXE一起添加 当我在开发机器上运行安装程序时,一切正常。但是,当我将安装程序复制到安装了.Net Framework 3.5和.Net Framework 4的空白虚拟机时,安装程序会说所有内容都已成功

我目前正在从事一个C#WPF项目,该项目使用MySQL.Data和System.Data.Sqlite dll以及其他几个dll

该项目是一个.NET4项目,在我的开发机器上运行没有问题。我创建了一个MSI安装程序包,当我添加可执行文件时,VisualStudio会计算出依赖项并将所需的DLL与EXE一起添加

当我在开发机器上运行安装程序时,一切正常。但是,当我将安装程序复制到安装了.Net Framework 3.5和.Net Framework 4的空白虚拟机时,安装程序会说所有内容都已成功安装,当我查看program files文件夹时,所有DLL也都在那里,但当我尝试运行该软件时,该软件不会加载,.Net运行时错误会显示在事件查看器中

错误如下

应用程序:MySQLBackup.exe框架版本:v4.0.30319 描述:由于未处理的异常,进程已终止。 异常信息:System.IO.FileLoadException堆栈:位于 MySQLBackup.App.Application_启动(System.Object, System.Windows.StartupEventArgs)位于 System.Windows.Application.OnStartup(System.Windows.StartupEventArgs) 在System.Windows.Application.b__1(System.Object)处 System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, 对象,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, 清除代码,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、, 在MS.Win32.HwndWrapper.WndProc(IntPtr,Int32, IntPtr,IntPtr,Boolean ByRef)在 位于的MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object) System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, 对象,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.UnsafentiveMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)在 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-around
InitialiseComponent()
方法,该方法在应加载的第一个对话窗口上执行,但该捕获从未被捕获,因此我无法看到导致错误的原因

我怎样才能找出这个问题并解决它

How can I figure out what this problem is and fix it.
使用执行远程调试

给出了如何使用它的想法

一旦您熟悉了VS远程调试,您将始终使用这个强大的工具在潜在的客户机环境中进行测试


至于您的特定问题,Application.Startup事件处理程序中有一些代码试图加载某些文件,但失败了。如果您自己无法找到问题源,请在App.xaml中发布代码,以便我们进行分析

根据堆栈跟踪,问题发生在OnStartup调用的应用程序启动中。因此,您应该检查您是否在代码中实现/重写或连接到可能引发这些异常的事件。由于可以有多个方法订阅事件处理程序,因此不能保证问题在代码中

您可以创建一些日志检查点来帮助缩小错误的位置,以及错误上下文中的日志值

您还可以使用远程调试来尝试缩小错误的位置

还有一些未处理的异常甚至处理程序,您可以通过谷歌搜索并了解如何实现,以便在出现错误时执行日志记录,但通常在这一点上,除了优雅地关闭之外,要获得更多信息还为时太晚,所以这可能是一种alst ditch方法

您还可以使用类似这样的sysinternal工具来确定程序试图访问的文件,并过滤到故障:

您可以确定它试图访问的最后一个文件是什么,甚至可能在操作系统级别看到错误是什么。我发现这个工具在处理奇怪的文件访问问题时很有价值。菲古需要一段时间