C # Winform application does not work on other computers (Mysterious Hang On Startup)

I made a winforms application in Visual Studio. This application is a simple Hello World application that, when clicked, changes the text of the Hello World button.

Here is the code below:

using System;
using System.Windows.Forms;

namespace HelloWorld
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            try
            {
                InitializeComponent();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                button1.Text = "Hello World";
                button1.Enabled = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
    }
}

When I try to open this program on my development computer, everything works fine. I tried running on 10 different Windows PCs with .NET 3.5 installed (my target platform), and each of them does the same.

, , , , - , ... . 3 , . " " - .

, , , debugdiag procdump. ... " ReadProcessMemory". debugdiag... 0 . procdump... .

- ...

using System;
using System.Windows.Forms;

namespace HelloWorld
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            try
            {
                System.Windows.Forms.Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
                System.Windows.Forms.Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(OnGuiUnhandedException);
                AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new Form1());
            }
            catch (Exception e)
            {
                HandleUnhandledException(e);
            }
            finally
            {
                // Do stuff
            }
        }

        private static void HandleUnhandledException(Object o)
        {
            // TODO: Log it!
            Exception e = o as Exception;

            if (e != null)
            {

            }
        }

        private static void OnUnhandledException(Object sender, UnhandledExceptionEventArgs e)
        {
            HandleUnhandledException(e.ExceptionObject);
        }

        private static void OnGuiUnhandedException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            HandleUnhandledException(e.Exception);
        }
    }
}

MessageBox program.cs Main(). 10 . , , :

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());

, , - Visual Studio.

, :

  • winforms Visual Studio 2015
  • .Net 3.5
  • , .
  • x86

:

  • .
  • Tried ClickOnce
  • Tried InstallShield Limited

. ... 3 , , . , , . , . ClickOnce InstallShield - . ...

2.0, 3.0, 3.5, 4.0, 4.5, 4.5.2.NET , ​​ . - 7 8.1. HelloWorld ? - Visual Studio?

+4
1

, , . , . 4.5.2. .

, 4.5.2, , .

, .

+1

Source: https://habr.com/ru/post/1616382/


All Articles