2009-06-22 204 views
0

C#VS 2005C#应用程序无法运行

我已经开发了我的开发机上完美运行,当我安装的应用程序。但是,它不能在任何客户端计算机上运行。

我曾与VMWare测试了新安装的Windows,并且仍然是应用程序不运行。

我已添加日志记录以尝试并确定应用程序失败的位置。我以前的版本工作,经过一个星期的发展,我给了客户,然后经历了这个问题。

我在构造函数和Form_Load事件的开始和结束进入记录。构造函数运行正常。但是,在构造函数结束时,它不会在form_load事件中运行,因为我有一个应该打印出来的日志语句。

当应用程序运行时,它会显示几秒钟,在任务管理器,然后加载失败。

我认为这可能是一个很难解决的问题。所以如果有人以前经历过这种情况,或者可以指出我正确的方向来解决这个问题。

表单加载事件中的代码。

private void CATDialer_Load(object sender, EventArgs e) 
{ 
    my_logger.Info("Start of form load event"); // Doesn't display this. 
    . 
    . 
} 

=====编辑静态主====

[STAThread] 
    static void Main() 
    { 
     Application.SetCompatibleTextRenderingDefault(false); 

     // Get the language and set this cultureUI in the statusdisplay that will 
     // change the language for the whole program. 
     string language = CATWinSIP.Properties.Settings.Default.Language; 
     if (language == "th-TH") 
     { 
      StatusDisplay.StatusDisplay status_display = new StatusDisplay.StatusDisplay(true); 
     } 
     else if(language == "en-GB") 
     { 
      StatusDisplay.StatusDisplay status_display = new StatusDisplay.StatusDisplay(false); 
     } 
     try 
     { 
      Application.Run(new CATDialer()); 
     } 
     catch (Exception ex) 
     { 
      Console.WriteLine(ex.Message); 
     } 

===构造===

public CATDialer() 
{ 
    //Set the language for all the controls on the form. 
    //Has to be done before all components are initialized. 
    //If not Thai language then must be using English. 
    if (Settings.Default.Language == "th-TH") 
    { 
     Thread.CurrentThread.CurrentUICulture = new CultureInfo("th-TH"); 
    } 
    else 
    { 
     Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-GB"); 
    } 

    InitializeComponent(); 

    this.statusDisplay1.BalanceStatus = CATWinSIP_MsgStrings.BalanceStatus; 
    this.statusDisplay1.RedialHistory = CATWinSIP_MsgStrings.RedialHistory; 
    this.statusDisplay1.LoginStatus = CATWinSIP_MsgStrings.LoginSuccessful; 

    // Enable logging 
    XmlConfigurator.Configure(); 
    logger.Info("CATDialer Constructor(): XmlConfigurator.Configure() Loaded [ OK ]"); 
    // MessageBox.Show("Balance Status: " + this.statusDisplay1.BalanceStatus); 

    //Short cut menu. 
    this.SetupShortCutMenu(); 

    this.fill_properties(); 

    logger.Debug("CATDialer Constructor(): Fill properties loaded [ OK ]"); 
} 

-

你好,

感谢您的所有建议。

我有问题,我创造了我的类库的一个使用的加密数据流。

我找到了答案时,我已将此添加到我的Program.cs

消息框显示失败的组件的信息。

感谢,

try 
{ 
    Application.Run(new CATDialer()); 
} 
catch (Exception ex) 
{ 
    MessageBox.Show(ex.ToString()); 
} 
+0

你可以发布任何应用程序对象的`static main`和`ctor`吗? – 2009-06-22 05:30:46

回答

3

你有不同的开发机器上检查?您的系统是否运行.net框架的相同版本? .net框架是否在远程系统上正确安装?您是否在不同的环境中测试了您的应用程序?

编辑:你试过垃圾邮件你的日志?把整个东西包裹起来,看看你能捕捉到什么。有时候我发现使用对这种日志记录很有用的消息框(MessageBox.Show())

2

您可能需要发布一些有关正在抛出的异常的类型以获得最大帮助的详细信息。

如果所有明显的检查,如具有正确的框架版过关,失败,接下来的事情往往是一个缺少组件。

如果是这种情况,您可能需要排查程序中的程序集加载问题。

MS Assembly Binding Log Viewer (fuslogvw)是一个有价值的工具包。

1

在这种情况下,我经常会发现.NET程序集绑定日志查看器(Fusion)在查找正在发生的事情时非常有用。通过融合,您可以看到哪些组件正在加载以及从哪里加载。对你来说更重要的是,可以启用它,以便融合也显示无法加载的组件,以及.NET试图加载它们的组件。

查看MSDN融合文章,如果您认为这可能有所帮助。