InvalidProgramException in Windows Forms application

Vadym Lenda 20 Reputation points


I'm a developer of the desktop .NET Windows Forms application.

I faced a strange exception thrown by .NET runtime on a single production PC.

On a component initialization phase .NET throws the following:

System.InvalidProgramException: Common Language Runtime detected an invalid program.    at System.Windows.Forms.DataGridViewColumnCollection.GetColumnAtDisplayIndex(Int32 displayIndex)    at System.Windows.Forms.DataGridView.CorrectColumnFrozenState(DataGridViewColumn dataGridViewColumn, Int32 anticipatedColumnIndex)    at System.Windows.Forms.DataGridView.OnAddingColumn(DataGridViewColumn dataGridViewColumn)    at System.Windows.Forms.DataGridViewColumnCollection.Add(DataGridViewColumn dataGridViewColumn)    at System.Windows.Forms.DataGridView.CorrectColumnFrozenStates(DataGridViewColumn[] dataGridViewColumns)    at System.Windows.Forms.DataGridView.OnAddingColumns(DataGridViewColumn[] dataGridViewColumns)    at System.Windows.Forms.DataGridViewColumnCollection.AddRange(DataGridViewColumn[] dataGridViewColumns)

What can cause the issue?

Where to dig to find a root cause?

Has anyone faced the same problems with Windows Forms?

Any information is highly appreciated.


Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,642 questions
Microsoft Technologies based on the .NET software framework.
2,077 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: The period of time during which a program is being executed in a computer.
1,044 questions
{count} votes

Accepted answer
  1. Jiale Xue - MSFT 11,441 Reputation points Microsoft Vendor

    Hi @Vadym Lenda ,

    You can of course fix the .NET runtime directly in your production environment.

    This is the official documentation for .NET runtime.Install .NET on Windows.

    If you want to delete the previous runtime, you can refer to this document:How to remove the .NET Runtime and SDK.

    Best Regards,


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

0 additional answers

Sort by: Most helpful