InvalidProgramException in Windows Forms application

Vadym Lenda 20 Reputation points
2023-08-29T18:10:10.3533333+00:00

Hello,

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.

Vadym.

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,892 questions
.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,843 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,159 questions
{count} votes

Accepted answer
  1. Jiale Xue - MSFT 45,006 Reputation points Microsoft Vendor
    2023-09-01T01:57:28.4633333+00:00

    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,

    Jiale


    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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.