none
[UWP][C#][C++/CX] Which language to use for UWP runtime components, C++/CX or C#? RRS feed

  • Question

  • Hi,

    We are currently working on writing a library of UI components with a certain design spec and want it to make it available to everyone, who want to make UWP apps.

    While writing that library, we came across this problem that which language to use for that library, C# or C++/CX. We understand that writing components in C# would be much easier with a lot more documentation and community help available. But we don't want to impose on our clients to have an additional dependency in the form of .Net.

    Can someone help me in clearing a few doubts I have:

    1. Is there a .Net dependency if we write the component in C++/CX?
    2. What additional dependencies are added if we write a component in C# vs C++/CX?
    3. I read about .Net Native which transpiles the .Net code to native code. Does it mean that there is no additional .Net dependency if the compilation is done with .Net Native enabled?
    4.  Would there be any difference in dependencies if the app using our library is written in C# vs C++/CX?

    Thanks,

    Shivang


    • Edited by nimitz92 Wednesday, August 2, 2017 12:44 PM
    Wednesday, August 2, 2017 12:41 PM

Answers

  • Hello,

    1. No C++/CX doesn't have any .NET dependencies. Is pure native, and relay on auto reference counting for destroy objects.

    2.If you write component in C# then it will have dependency to .NETCore . And note you cannot directly consume  C# component from C++/CX project, you should use COM API  provided by WRL.

    3. .NETNative just AOT compiler tool chain for MSIL.  What this mean, the tool chain compile MSIL to processor native code at build time unlike JIT which  compile MSIL to processor native code at run time. But app still managed by CLR.

    4. Yes difference is .NETCore and CoreCLR for C#


    Make the community better together

    • Marked as answer by nimitz92 Wednesday, August 16, 2017 7:52 PM
    Thursday, August 3, 2017 5:32 AM
  • Hi nimitz92

    >> "And note you cannot directly consume C# component from C++/CX project, you should use COM API provided by WRL."

    It is not correct, C# runtime component could be used directly by C++/Cx project.

    Best Regards

    Roy 


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by nimitz92 Wednesday, August 16, 2017 7:52 PM
    Tuesday, August 8, 2017 9:02 AM
    Moderator

All replies

  • Hello,

    1. No C++/CX doesn't have any .NET dependencies. Is pure native, and relay on auto reference counting for destroy objects.

    2.If you write component in C# then it will have dependency to .NETCore . And note you cannot directly consume  C# component from C++/CX project, you should use COM API  provided by WRL.

    3. .NETNative just AOT compiler tool chain for MSIL.  What this mean, the tool chain compile MSIL to processor native code at build time unlike JIT which  compile MSIL to processor native code at run time. But app still managed by CLR.

    4. Yes difference is .NETCore and CoreCLR for C#


    Make the community better together

    • Marked as answer by nimitz92 Wednesday, August 16, 2017 7:52 PM
    Thursday, August 3, 2017 5:32 AM
  • For your second point

    "And note you cannot directly consume  C# component from C++/CX project, you should use COM API  provided by WRL."

    We created a C# windows runtime component as a separate winmd file and included it in C++/CX project which worked fine. So what exactly do you mean when you say the above line.

    Sunday, August 6, 2017 7:44 AM
  • Hi nimitz92

    >> "And note you cannot directly consume C# component from C++/CX project, you should use COM API provided by WRL."

    It is not correct, C# runtime component could be used directly by C++/Cx project.

    Best Regards

    Roy 


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by nimitz92 Wednesday, August 16, 2017 7:52 PM
    Tuesday, August 8, 2017 9:02 AM
    Moderator