简体   繁体   English

C#应用程序未运行

[英]C# Application not run

C# VS 2005. C#VS 2005。

I have developed an application that run perfectly on my development machine when I install it. 我已经开发了一个可以在我的开发机器上完美运行的应用程序。 However, it doesn't run on any of the clients machines. 但是,它不能在任何客户端计算机上运行。

I have tested with VMWare with a fresh install of windows, and still the application doesn't run. 我已经使用全新安装的Windows对VMWare进行了测试,但该应用程序仍然无法运行。

I have added logging to try and determine where the application is failing. 我添加了日志记录,以尝试确定应用程序在哪里失败。 My previous versions worked, and after a week of development I gave to the client and then experienced this problem. 我以前的版本工作正常,经过一周的开发,我交给了客户,然后遇到了这个问题。

I have entered logging at the start and end of the constructor and form_load event. 我已经在构造函数和form_load事件的开始和结束处输入了日志记录。 The constructor runs ok. 构造函数运行正常。 However, at the end of the constructor it doesn't run in the form_load event as I have a log statement that should print out. 但是,在构造函数的末尾,它没有在form_load事件中运行,因为我有一条应该打印出的日志语句。

When the application runs it displays for a few seconds in task manager then fails to load. 当应用程序运行时,它将在任务管理器中显示几秒钟,然后无法加载。

I think this could be a very difficult problem to solve. 我认为这可能是一个很难解决的问题。 So if anyone has experienced this before or could point me in the right direction to solve this problem. 因此,如果有人以前经历过,或者可以为我指出正确的方向来解决此问题。

The code in the form load event. 表单加载事件中的代码。

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

===== Edit static main ==== =====编辑静态主====

[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);
        }

=== Constructor === ===构造函数===

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 ]");
}

-- -

Hello, 你好,

Thanks for all the advice. 感谢所有的建议。

I have problem with one of my class libraries I created that used a crypto stream. 我创建的使用加密流的一个类库存在问题。

I found the answer when I added this to my program.cs 当我将其添加到program.cs中时,我找到了答案

The message box displayed the information for the failed assembly. 该消息框显示了失败的程序集的信息。

Thanks, 谢谢,

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

Have you checked on a different development machine? 您是否检查过其他开发机器? Are your systems running same version of the .net framework? 您的系统是否运行相同版本的.net框架? Is the .net framework installed correctly on the remote system? .net框架是否已正确安装在远程系统上? Have you tested your application in a different environment? 您是否在其他环境中测试过您的应用程序?

edit: have you tried spamming your log? 编辑:您是否尝试向日志发送垃圾邮件? Wrap the entire thing in a try catch and see what you can capture. 将整个内容包装在一个try catch中,看看可以捕获什么。 Sometimes I found using the messagebox useful for this kind of logging (MessageBox.Show()) 有时我发现使用消息框对于这种记录很有用(MessageBox.Show())

You probably need to post a bit more detail about the type of exception that is being thrown to get the most help. 为了获得最大的帮助,您可能需要发布有关抛出的异常类型的更多详细信息。

If all the obvious checks such as having the correct framework version pass, the next thing to fail can often be a missing assembly. 如果所有显而易见的检查(例如,具有正确的框架版本)都通过了,则下一失败的原因通常可能是缺少程序集。

If this is the case you may want to troubleshoot assembly loading in your app. 如果是这种情况,您可能要对应用程序中的程序集加载进行故障排除。

The MS Assembly Binding Log Viewer (fuslogvw) is a valuable piece of kit for this task. MS Assembly绑定日志查看器(fuslogvw)是完成此任务的重要工具。

In this sort of scenario I frequently find .NET assembly binding log viewer (Fusion) very useful in finding out what is going on. 在这种情况下,我经常发现.NET程序集绑定日志查看器(Fusion)在发现正在发生的事情中非常有用。 With fusion you can see which assemblies are being loaded and where they are being loaded from. 通过融合,您可以看到正在加载的程序集以及从何处加载它们。 More importantly for you, it is possible to enable it so that fusion also displays the assemblies that fail to load and where .NET tried to load them from. 对您而言更重要的是,可以启用它,以便融合也显示无法加载的程序集以及.NET尝试从中加载它们的位置。

Check out the MSDN article on fusion if you think this might help. 如果您认为这可能有所帮助,请查看有关融合的MSDN文章。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM