System.IO.FileLoadException不同的计算机上运行的C#程序时 [英] System.IO.FileLoadException when running C# program on a different computer

查看:192
本文介绍了System.IO.FileLoadException不同的计算机上运行的C#程序时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前工作的一个C#WPF项目,该项目利用了MySQL.Data和System.Data.Sqlite DLL,以及其他几个。



该项目是一个.NET 4项目,该项目不会对我的机器问题的作品。我创建一个MSI安装程序包,当我添加可执行文件的Visual Studio作品出来的依赖,并添加所需的DLL与EXE文件。



当我在我的开发机器上运行安装程序,一切工作正常。然而,当我安装程序复制到空白的虚拟机与.NET Framework 3.5的和.NET Framework 4安装时,安装说,一切都已经安装成功,当我看在Program Files文件夹的所有DLL文件有作为,但是当我尝试运行该软件不会加载软件,并在事件查看器显示.NET运行时错误。



错误如下:




应用:MySQLBackup.exe Framework版本: v4.0.30319
说明:该过程由于未处理的异常终止。
异常信息:System.IO.FileLoadException堆栈:在在
System.Windows.Application
MySQLBackup.App.Application_Startup(System.Object的,
System.Windows.StartupEventArgs)。 OnStartup(System.Windows.StartupEventArgs)
在System.Windows.Application< .ctor>在
System.Windows.Threading.ExceptionWrapper.InternalRealCall b__1(System.Object的)(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,
系统。 Threading.ContextCallback,System.Object的)留在
系统
System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext,
System.Threading.ContextCallback,System.Object的,布尔)。 Threading.ExecutionContext.Run(System.Threading.ExecutionContext,
System.Threading.ContextCallback,System.Object的)留在
System.Windows
System.Windows.Threading.DispatcherOperation.Invoke() .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的在在
System.Windows.Threading.Dispatcher
MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG
为ByRef)的Int32,IntPtr的,IntPtr的)
。 PushFrameImpl(System.Windows.Threading.DispatcherFrame)留在System.Windows.Threading.Dispatcher
System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame)

。运行()留在
System.Windows.Application在
System.Windows.Application.RunInternal(System.Windows.Window)
System.Windows.Application.RunDispatcher(System.Object的)。润(System.Windows.Window)在
System.Windows.Application.Run()在MySQLBackup.App.Main()




错误消息并没有真正帮助我弄清楚什么是错了,所以在应用程序启动时我加试catch语句,但异常没有抓到。我还添加了尝试捕捉周围InitialiseComponent(),这是一个应该载入第一次对话窗口上执行的方法,但同样渔获没有抓到,所以我看不出是什么原因造成的错误。



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



感谢您的帮助,您可以提供将不胜感激。


解决方案

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



使用的 Visual Studio远程调试



本教程给出了如何使用它的想法。



一旦你熟悉了VS远程调试,你将永远使用这个强大的工具来测试一个潜在的客户端环境



至于你的具体问题,你必须在尝试加载一些文件和失败Application.Startup事件处理一些代码。在你App.xaml中发布代码,所以我们可以分析一下,如果你不能够自己找到问题根源。


I am currently working on a C# WPF project which makes use of the MySQL.Data and System.Data.Sqlite dll as well as a couple of others.

The project is a .Net 4 project which works without problems on my Development Machine. I create an MSI installer package and when I add the executable Visual Studio works out the dependencies and adds the required DLL's with the EXE.

When I run the installer on my development machine everything works fine. However, when I copy the installer to a Blank Virtual machine with .Net Framework 3.5 and .Net Framework 4 installed the installer says that everything has installed successfully, when I look in the program files folder all the DLLs are there as well, but when I try to run the software the software doesn't load and .Net Runtime error is shown in the event viewer.

The error is as follows

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()

the error message doesn't really help me to figure out what is wrong so in the Application Start up event I added try catch statements but the exception is never caught. I also added try catch around InitialiseComponent() method which is executed on the first dialogue window that should load, but again the catch is never caught so I cannot see what is causing the error.

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

Thanks for any help you can provide would be greatly appreciated.

解决方案

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

Perform a remote debug using the visual studio remote debugger.

This tutorial gives an idea of how to use it.

Once you get familiar with the VS Remote Debug, you will always use this powerful tool to test on a potential client environment.

As for your particular problem, you have some code in the Application.Startup event handler that tries to load some file and fails. Post a code in your App.xaml so we can analyze, if you won't be able to find the problem source yourself.

这篇关于System.IO.FileLoadException不同的计算机上运行的C#程序时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆