I have an application that I've upgraded from .NET Core 3.0 to .NET Core 3.1. After doing this, my application no longer compiles due to missing reference to MenuItem and ContextMenuItem (from Winforms System.Windows.Forms namespace).
I've tried:
- Restarting Visual Studio
- Clean/Rebuild
- Close Visual Studio and delete bin and obj folders
- Changed my error display to Build only to avoid possible IntelliSense bugs
Unfortunately, the errors persist. What is extra puzzling is that other WinForms objects are referenced and do not cause compile errors, such as System.Windows.Forms.PropertyGrid
. Here is a screenshot showing that PropertyGrid is successfully referenced, but access to its ContextMenu property causes a compile error.
How can I solve this problem?
CodePudding user response:
ContextMenu along with some other controls is not available in .NET Core 3.1 and later versions. Those controls (including MainMenu, ContextMeby, Toolbar, DataGrid) were first removed form toolbox and the types were available until .NET Core 3. Then later the types also removed starting .NET Core 3.1.
You need to upgrade your application and use the replaced controls (MenuStrip, ContextMenuStrip, ToolSTrip, DataGridView) instead.
You can read more about breaking changes and removed controls in .NET Core 3.1 here: