Unable to access CLR module from MFC application RRS feed

  • Question

  • Hello All,

        We have a legacy MFC application I am trying to add WPF controls inside an MFC application. I couldn't get the main application to compile with /clr option. So, I added new dll (WPFHost) and compiled it with /clr option. I have another class library with WPF controls that I am trying to invoke from WPFHost dll. The main application linked correctly to the WPFHost dll but when I try to invoke code from the main application, it throws a debug assertion and crashes.The main problem here is it doesn't even hit the constructor of the class that I am trying to invoke inside the WPFHost dll. When I tried to keep a break point, it doesn't let me do it. Visual Studio says that this breakpoint will not be hit.

    I am pretty new to this MFC and WPF interop and am not sure what else I should be doing to make this work. Any suggestions and pointers are greatly appreciated.


    Thanks a lot,




    Tuesday, November 9, 2010 4:45 PM


All replies

  • Hi,

    Thanks for your post. Following is a how-to article addressing how to host a Windows Presentation Foundation (WPF) Control in the client area of an MFC Application and to enable Cut-and-Paste event handling in MFC that can cut-and-paste text in the WPF controls. It could be helpful.

    Hosting a WPF Control in MFC and Enable Cut-and-Paste

    BTW, please also take a look at How to: Compile MFC and ATL Code with /clr.


    Please mark the right answer at the right time.
    • Edited by SamAgain Wednesday, November 10, 2010 9:48 AM refine
    • Marked as answer by A P S Wednesday, November 10, 2010 1:15 PM
    Wednesday, November 10, 2010 9:47 AM
  • Thanks for the links. I will take a look. I will be back if I have more problems.


    It looks like I cannot debug unmanaged and managed code at the same time and thats why the breakpoints were not being hit. Is there a way to debug interop applicatons like the one described in my original post?




    Wednesday, November 10, 2010 1:20 PM