System.ComponentModel.InvalidAsynchronousStateException

0

I am getting this Exception during run time:

System.ComponentModel.InvalidAsynchronousStateException HResult=0x80070057 Message=An error occurred invoking the method. The destination thread no longer exists. Source=System.Windows.Forms StackTrace: at System.Windows.Forms.WindowsFormsSynchronizationContext.Send(SendOrPostCallback d, Object state) in f:\dd\ndp\fx\src\winforms\Managed\System\WinForms\WindowsFormsSynchronizationContext.cs:line 89

The really weird part is that the exception is showing up here:

static void Main()
{
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
  // AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
    Application.Run(new Form1());        
}

at the Aplication.Run(new Form1)); so I do not know where it is happening at. How do I troubleshoot this? The call Stack was not much help :

System.Windows.Forms.dll!System.Windows.Forms.WindowsFormsSynchronizationContext.Send(System.Threading.SendOrPostCallback d, object state) Line 81 C# System.dll!Microsoft.Win32.SystemEvents.SystemEventInvokeInfo.Invoke(bool checkFinalization, object[] args) Unknown System.dll!Microsoft.Win32.SystemEvents.RaiseEvent(bool checkFinalization, object key, object[] args) Unknown System.dll!Microsoft.Win32.SystemEvents.OnUserPreferenceChanging(int msg, System.IntPtr wParam, System.IntPtr lParam) Unknown System.dll!Microsoft.Win32.SystemEvents.WindowProc(System.IntPtr hWnd, int msg, System.IntPtr wParam, System.IntPtr lParam) Unknown [Native to Managed Transition] [Managed to Native Transition]
System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(System.IntPtr dwComponentID, int reason, int pvLoopData) Line 2079 C# System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason, System.Windows.Forms.ApplicationContext context) Line 3424 C# ?System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context) Line 3306 C# Pixelation Tool.exe!Pixelation_Tool.Program.Main() Line 21 C#

Update

 public Form1()
    {
        multiple_instances();
        MakePoints();
        InitializeComponent();

        makeDirectory();
        loadAllSettings();
        readAllSettings();

        PLCConnect();
        VisualCamConnect();

        ConnectKim101();

        getavailableMemory();
        this.Text = "Pixelation Tool:" + GetApplicationVersion();
        p2.Size = new Size(1184, 718);

        p2.Location = new System.Drawing.Point(224, 12);
        p2.SizeMode = PictureBoxSizeMode.Zoom;


        this.Controls.Add(p2);
        this.FormClosing += Form1_FormClosing;

        this.wafer1.OnEllipseClick += wafer1_OnEllipseClick;


    }
c#
exception
asked on Stack Overflow Oct 25, 2019 by Nia2 • edited Oct 25, 2019 by Nia2

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0