C++/CX component "public enum class" Does not link correctly in C# Metro App. RRS feed

  • Question

  • Hi, i'm trying to wrap D3D11 calls in an API ive been developing.

    Ive made a C++/CX component library that i'm trying to use in C#.  This is simple and straightforward if the C++/CX component and C# project are in the SAME solution, everything will work fine...

    ...but if I create my C++/CX API component in its OWN solution then create a second C# Metro App solution and add my C++/CX component "project" to it and then have my C# Metro App reference the C++/CX component project I get runtime errors when trying to use public enums that were declared in C++.

    Here is the public enum class error that my C# app cant seem to link to.

    "Could not find Windows Runtime type 'Reign.Video.D3D11.FeatureLevels'."

    This is rly frustrating as I can't seem to get my C++/CX "API" stuff to link correctly in a C# app for TESTING.  How are you suppose to productively test an API made in C++ on metro??  You can't link a C++/CX component to a C# project unless there in the same solution and if you try to link the C++/CX project to the C# solution and link it from there you get runtime errors...

    Saturday, August 4, 2012 3:25 AM


All replies

  • Hello,


    Thanks for your feedback, I will involve more experts to investigate it.


    Best regards,


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

    Monday, August 6, 2012 9:18 AM
  • I can't reproduce any problem here

    public enum class FeatureLevels

    I can add a reference to this windows runtime component to both C# and C++ projects and reference the enum class without errors.

    Can you give exact repro steps and errors?

    Monday, August 6, 2012 9:11 PM
  • Ok I figured out that when you use any other namespace other then that of the 'Project Name'... runtime linking(or something) does not work correctly. I'm going to send you a very simple demo for demonstration.

    Download Demo 'http://www.reign-studios.com/Share/MetroDemo.zip'

    Basically defining something like this in C++ will not link correctly at runtime in a C#(.NET) project.

    namespace Reign
    {namespace Video
    {namespace D3D11
        public enum class FeatureLevels

    • Edited by zezba9000 Tuesday, August 7, 2012 7:44 PM
    Tuesday, August 7, 2012 7:37 PM
  • My question was answered here: http://stackoverflow.com/questions/11805669/c-cx-component-public-enum-class-does-not-link-correctly-in-c-sharp-metro-ap/11853596#11853596

    "Windows Runtime requires that all types must be found in a namespace that matches the name of the containing .winmd file"

    I would recommend MS adding a compile time error for this situation, unless its technically unrealistic.

    • Marked as answer by zezba9000 Tuesday, August 7, 2012 9:25 PM
    Tuesday, August 7, 2012 9:25 PM