locked
Tinkering with Wrl idl Namespaces

    General discussion

  • Hi all!  Here are just a few dilemmas I have been working on...

    TINKERING WITH WRL IDL NAMESPACES

    When you create an *.idl on your WRL component project the name of the project becomes the "root" namespace.  If you change the "<ProjectName>" value in the [myWrlProj.vcxproj] your project name and the "root" namespace is also changed.  A note, the "<RootNamespace>" although suggest to be the place where you change the "root" namespace is ignored.

    Once you provide a project name you can't create types in your *.idl outside that namespace, for example (*.idl):

    namespace Wrl {

    namespace Frutas {

       interface IFrutoso;

       ... // the rest if your Frutoso interface and runtimeclass declarations...

    namespace Agrias {

       interface IAgrioso;

       ... // the rest if your Agrioso interface and runtimeclass declarations...

    }

    }

    namespace Viandas {

       interface IDulces;

       ... // the rest if your Dulces interface and runtimeclass declarations...

    }

    }

    Although it compiles ok when you reference the above Wrl::Viandas::Dulces (in another) consumer project you will get the following message:

    The .winmd file 'Wrl.Frutas.winmd' contains type 'Wrl.Viandas.Dulces' outside its root namespace 'Wrl.Frutas'.

    By removing the Viandas namespace and recompile your component all is OK and it consumable by others.

    Therefore, make sure that you choose the name of your project wisely.

     
    Wednesday, January 16, 2013 11:10 AM

All replies

  • Hi,

    I found the document, and it said.

    A Windows Runtime component can contain multiple public activatable classes as well as additional classes that are known only internally to the component. All public classes must reside in the same root namespace which has the same name as the component metadata file.

    Please check
    http://msdn.microsoft.com/en-us/library/windows/apps/hh441569.aspx

    Best regards,
    Jesse


    Jesse Jiang
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, January 18, 2013 5:38 AM
  • Thanks Jesse for the note.

    So I renamed the above *.idl as "Wrl" compile it and try to consume it elsewhere still "Viandas" is considered to be "outside the root namespace".  My guess is that it has nothing to do with the name of the "idl" as the documentation (looks like) wrongly points out.

    And then, how about adding another *.idl in the same project?  It generates as many *.winmd's as *.idl's; still it looks like it picks one to be implemented since types declared in the other *.idl for some reason are not accessible.

    Another Note, if an idl is named Calabaza still in the project file the root namespace is called "Wrl" it will generate 2 *.winmd's and that is fine still the second looks like it serves no purpose.

    So I erase everything and start over again, I have my project name "Wrl.Application", in the project file set the root namespace as "Wrl" and created an *.idl named Calabaza therefore I get the 2 winmd's the expected Calabaza.winmd and the other also expected Wrl.winmd.  So I get the usable Calabaza *.winmd with my nice Calabaza::Frutas::Frotoso type compiling OK, but at the time I will consume it I got the nice "warning APPX1707: No implementation file was provided for the .winmd file..." message and the type "Frotoso" can't be used since while trying to create an instance it crashes the app.

    I am not getting the story right as the documentation tries to point out. I guess I will write how it is really working at a later time.

    Anyways, thanks for the note!



    Friday, January 18, 2013 11:36 AM