RSS

Using /clr and incompatibility troubleshooting in MFC applications

16 Apr

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!

clip_image002

However this will result in another conflict:

clip_image003

To troubleshoot this, change the setting for this specific cpp file, and change the /Yu to /Yc:

clip_image005

Rebuild ! Now it works!

You can enjoy the Winform and CLR features without changing the entire project with the “/clr” directive!

Advertisements
 
Leave a comment

Posted by on April 16, 2011 in Dotnet/C#, MFC

 

Tags:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: