加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

在另一台计算机上运行C#程序时出现System.IO.FileLoadException

发布时间:2020-12-16 01:47:27 所属栏目:百科 来源:网络整理
导读:我目前正在开发一个C# WPF项目,该项目使用 MySQL.Data和System.Data.Sqlite dll以及其他几个. 该项目是一个.Net 4项目,在我的开发机器上没有问题.我创建了一个MSI安装程序包,当我添加可执行文件Visual Studio时,计算出依赖关系,并在EXE中添加所需的DLL. 当我
我目前正在开发一个C# WPF项目,该项目使用 MySQL.Data和System.Data.Sqlite dll以及其他几个.

该项目是一个.Net 4项目,在我的开发机器上没有问题.我创建了一个MSI安装程序包,当我添加可执行文件Visual Studio时,计算出依赖关系,并在EXE中添加所需的DLL.

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

错误如下

Application: MySQLBackup.exe Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileLoadException Stack: 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,Boolean) at
System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext,System.Object) at
System.Windows.Threading.DispatcherOperation.Invoke() at
System.Windows.Threading.Dispatcher.ProcessQueue() at
System.Windows.Threading.Dispatcher.WndProcHook(IntPtr,IntPtr,
IntPtr,Boolean ByRef) at MS.Win32.HwndWrapper.WndProc(IntPtr,Boolean ByRef) at
MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object) at
System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate,System.Delegate) at
System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority,
System.TimeSpan,System.Delegate,Int32) at
MS.Win32.HwndSubclass.SubclassWndProc(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,但是从来没有捕获到catch,所以我看不出导致错误的原因.

我怎样才能弄清楚这个问题是什么并修复它?

解决方法

How can I figure out what this problem is and fix it.

使用visual studio remote debugger执行远程调试.

This tutorial给出了如何使用它的想法.

熟悉VS远程调试后,您将始终使用此强大的工具来测试潜在的客户端环境.

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读