none
Resource on how to use C++ CX in a normal WPF Desktop App (on Windows 7?) RRS feed

  • Question

  • In my desktop app I am using both C# and Managed C++

    I wonder if, going forward, I would be able to use C++ CX (instead of Managed C++) as it seems faster to run and easier to use.

    Note that I'm not going to port my App to metro and I plan on continue writing desktop app.

    Also, would I be able to deploy my app (using C++ CX) on Windows 7?

    Thursday, June 7, 2012 3:19 AM

Answers

All replies

  • WPF is a managed application, right?

    C++/CX creates native code.

    Yes, it can use XAML for the UI, if that is what you mean.

    You cannot deploy this on Windows 7.

    You will need to create the core engine using C++ and write different UI that uses the same engine for Windows 7 and Windows 8.

    You could use C++/CLI for Windows 7 and C++/CX for Windows 8.


    «_Superman_»
    Microsoft MVP (Visual C++)

    Polymorphism in C

    Thursday, June 7, 2012 4:38 AM
  •  

    Hello,

     

    C++/CX is based on WRL, which was designed to support the new API model in Windows 8. Therefore, you can not use it in Windows 7 now.

     

    Inside the C++/CX Design

    http://blogs.msdn.com/b/vcblog/archive/2011/10/20/10228473.aspx

     

    But on other hand, it is based on native C++, COM. If there is achieve of WRL, maybe it can be used in Windows 7.

     

    Best regards,

    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, June 7, 2012 7:14 AM
    Moderator
  • Correction - C++/CX is based on WRT (Windows RunTime).


    «_Superman_»
    Microsoft MVP (Visual C++)

    Polymorphism in C

    Thursday, June 7, 2012 7:17 AM
  • I don't want to use WinRT for various reason. One of them is no System.Data namespace or equivalent!!
    (No I'm not going to write a service for that, I'd rather my database if I could, but I prefer SQLServer to SQLite)

    I guess I'll have to stick to C+ CLR then.. :/

    Why can't they provide C++ CX for desktop is annoying!!

    Thursday, June 7, 2012 8:15 AM
  • Hello,

     

    As far as I know, a part of Windows API reference for Metro style apps can be used in native codes, like ProximityDevice class . In the document, it said  Applies to: Metro style apps | desktop apps

    http://msdn.microsoft.com/en-us/library/windows/apps/windows.networking.proximity.proximitydevice.aspx

     

    It means that it can be used in native codes, but the not used C++/CX in native codes.

     http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/0b394fc4-c612-4e21-9f80-5d8437345cbd

     

    Therefore, you can try a part of  Data and content APIs in native codes.

    http://msdn.microsoft.com/en-us/library/windows/apps/br211377.aspx

     

    Best regards,

    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Friday, June 8, 2012 3:05 AM
    Moderator
  • I tried to create a new solution with a C++ Cx library named CxLibrary, it contains one class named Class1

    And a WPF application named WpfApplication1, in which I reference CxLibrary and platform.wimmd

    In my WPF app's constructor I try to instantiate Class1. According to intellisense and the compiler it's all good.

    When I run it I get this error:

    System.NotSupportedException: "Types from custom Windows Runtime components are not supported in desktop applications."

    mm... what to do, what to do??

    Wednesday, June 13, 2012 2:50 PM
  • The WPF application is desktop application, and the C++/CX used for metro application.

     

    It is hard to call a metro DLL in desktop application, like WPF.

     

    Best regards,

    Jesse



    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, June 14, 2012 9:22 AM
    Moderator
  • When I run it I get this error:
     
    System.NotSupportedException: "Types from custom Windows Runtime components are not supported in desktop applications."
     
    mm... what to do, what to do??
    Patient: It hurts when I do X.
     
    Doctor: Then don't do X.
     

    David Wilkinson | Visual C++ MVP
    Thursday, June 14, 2012 10:37 AM
  • If CLX will not produce desktop applications, can we still use C++/CLI on the metro desktop?
    Thursday, June 14, 2012 5:17 PM
  • If CLX will not produce desktop applications, can we still use C++/CLI on the metro desktop?
    What is metro desktop? You mean Windows 8 desktop? In that case: Yes, of course.
     

    David Wilkinson | Visual C++ MVP
    Thursday, June 14, 2012 6:06 PM
  • Hi,

    Would you mind letting me know the result of the suggestions? If you need further assistance, feel free to let me know. I will be more than happy to be of assistance.

    Best regards,
    Jesse



    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Monday, June 25, 2012 4:38 AM
    Moderator
  • Hi,

    You can't use the C++/CX for CRL, It is only for WinRT. CRL has its own way.

    Friday, March 13, 2015 3:41 AM