gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 14:16:28 24 4
gpt4 key购买 nike

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

该项目是一个 .Net 4 项目,可以在我的开发机器上正常运行。我创建了一个 MSI 安装程序包,当我添加可执行文件时,Visual Studio 会计算出依赖项并使用 EXE 添加所需的 DLL。

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

错误如下

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, 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 语句,但从未捕获到异常。我还添加了 try catch around InitialiseComponent() 方法,该方法在应该加载的第一个对话窗口上执行,但是 catch 永远不会被捕获,所以我看不出是什么导致了错误。

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

最佳答案

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

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

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

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

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

关于c# - 在另一台计算机上运行 C# 程序时出现 System.IO.FileLoadException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7450634/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com