In some circumstances, to use C# Winform or other .Net objects in MFC applications, the “/clr” directive should be used in the MFC project settings. However, it is found not always possible to use “/clr” to avoid conflicts with other projects in the same solution.
The workaround is to apply “/clr” on a specific cpp file, rather than on the entire project!
However this will result in another conflict:
To troubleshoot this, change the setting for this specific cpp file, and change the /Yu to /Yc:
Rebuild ! Now it works!
You can enjoy the Winform and CLR features without changing the entire project with the “/clr” directive!