Could not load type 'System.Windows.Forms.MenuMerge' from assembly 'System.Windows.Forms, Version=5.0.7.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

Zhen 6 Reputation points
2021-07-12T20:17:46.93+00:00

I upgrade my winform vb.net project from framework 4.7.2 to .net 5. It is compiling well. I got the runtime error "Could not load type 'System.Windows.Forms.MenuMerge' from assembly 'System.Windows.Forms, Version=5.0.7.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'".

Thanks in advance for any help!

PS
Assembly System.Windows.Forms
C: \ Program Files \ dotnet \ packs \ Microsoft.WindowsDesktop.App.Ref \ 5.0.0 \ ref \ net5.0 \ System.Windows.Forms.dll


Assembly System.Windows.Forms
Member of .NET Framework 2.0, .NET Framework 3.0, .NET Framework 3.5
C: \ Windows \ Microsoft.NET \ Framework \ v2.0.50727 \ System.Windows.Forms.dll

Developer technologies | Windows Forms
Developer technologies | VB
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Lex Li 6,037 Reputation points
    2021-07-13T02:41:03.057+00:00

    That type (as well as other obsolete WinForms types) has been removed from .NET Core in 3.1/5.0 time frame.

    You can find the progress tracked in GitHub issues like this.

    The solution, is not to use any obsolete items any more in your applications.


  2. Xingyu Zhao-MSFT 5,381 Reputation points
    2021-07-13T02:58:13.247+00:00

    Hi @Zhen ,

    Both MenuMerge and MenuItem are not supported in .net 5.
    Use ToolStripMenuItem instead, which replaces the MenuItem control.

    Hope it could be helpful.

    Best Regards,
    Xingyu Zhao
    *
    If the answer is helpful, please click "Accept Answer" and upvote it.
    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.


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.