为什么我的C#应用程序不能在另一台机器上运行?

4

我已经开发了大约两个月的应用程序。这是我第一次做这样规模的项目。现在,当我试图运行应用程序时,我接近拥有所有我想要的功能流程时,我遇到了下面的错误。

以前我创建过运行良好的应用程序......事实上,在其他机器上甚至更好。但是这个应用程序让我很棘手。

  Problem signature:
  Problem Event Name:    CLR20r3
  Problem Signature 01:    logopicking.exe
  Problem Signature 02:    1.0.0.0
  Problem Signature 03:    4f4e6509
  Problem Signature 04:    System.Drawing
  Problem Signature 05:    4.0.0.0
  Problem Signature 06:    4ba1e086
  Problem Signature 07:    30
  Problem Signature 08:    14
  Problem Signature 09:    System.IO.FileNotFoundException
  OS Version:    6.1.7601.2.1.0.768.3
  Locale ID:    1033
  Additional Information 1:    0a9e
  Additional Information 2:    0a9e372d3b4ad19135b953a78882e789
  Additional Information 3:    0a9e
  Additional Information 4:    0a9e372d3b4ad19135b953a78882e789

这就是它给我的错误。

为了添加更多信息,我会发布使用情况。

using System;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using Interop.QBFC11;

我不知道这些中有没有任何问题会导致应用程序无法启动。


1
仅仅因为你已经将引用添加到你的项目中,并不意味着这些文件都会自动出现在你的目标计算机上,或者这些文件会被注册(如果需要的话)。 - user153923
可能是加载dll时出现FileNotFoundException的重复问题。 - Alexei Levenkov
2个回答

6
你遇到了一个System.IO.FileNotFoundException的错误。你的应用程序试图访问一个文件,但在'different machine'上找不到它。
这个链接会帮助你更进一步:http://channel9.msdn.com/Forums/TechOff/258689-NET-20-Win-App-Eror-EventType-clr20r3 从那里得到的信息:
"实现一个UnhandledExceptionHandler并将异常信息记录到事件日志中,以便您可以获得有关导致应用程序崩溃及其上下文的更好信息。"
// C# 2.0
static void Main(string[] args)
{
  AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(
    delegate(object sender, UnhandledExceptionEventArgs e) {
      if (e.IsTerminating) {
        object o = e.ExceptionObject;
        Debug.WriteLine(o.ToString());
      }
    }
  );

  // rest of your Main code
}

哈哈...我写了一个本地地址的jpg文件,但在另一台机器上确实不存在。 - thepupil

3

根据System.IO.FileNotFoundException错误,您缺少组件或尝试读取不存在的文件。

请确保在第二台计算机上安装了正确版本的.Net框架(取决于您使用的Visual Studio版本),并且您可能还需要在第二台计算机上安装Quickbooks所需的任何内容。


.Net 4.0 很容易实现,但是 Quickbooks 的 Interop 文件很容易被忽视。这两个答案都对我有帮助。耶! - thepupil

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接