Hello shoucal
Hans is right that the native menu template resource is not compatibile with .NET menu objects. Visual Studio designer can parse the menu resource embedded in a resource dll simply because VS uses the native PE file interpreter to parse the resource. The interpreter is not related to .NET.
Here are two solutions in my mind:
Possible solution1.
Stick to P/Invoking native APIs to load and display the native menu resource in the winform app. You already P/Invoked LoadMenu, next you may need to P/Invoke TrackPopupMenu if it's a shortcut menu, and finally DestroyMenu.
Possible solution2.
The menu resource was generated by a .rc file. I'm aware of some third party tools that can convert .rc file to .NET objects. For example, http://www.dudelabs.com/Home.aspx. This tool is able to parse the native resources in the rc (e.g. the menu resource) and convert them to a Winform class with MenuStrip, ToolStripMenuItem objects.
If you do not want these tools, you may probably manually do the convertion.
This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.
Regards,
Jialiang Ge
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.