Dev Center - Metro style apps > Windows Metro style apps Forums > Building Metro style apps with C# or VB > xmlns using syntax for another assembly (UserControl cant find a sibling control)

Answered xmlns using syntax for another assembly (UserControl cant find a sibling control)

  • Thursday, October 13, 2011 6:50 PM
     
     

    I know in the WinRT XAML stack, the xmlns syntax has changed to "using:NamespaceHere".  This seems to work fine even when the namespace is in another referenced assembly.  For example, I have some controls over in another (metro) assembly and my metro application project has a reference to that.  So the xmlns:Controls="using:SeparateAssembly.Controls" syntax works fine.

    What is NOT working though, is then when a control in that separate assembly uses ANOTHER control in that separate assembly, I get a runtime exception that the 2nd control cannot be found.  I can use that control directly in my UI, but I can't use it from WITHIN the separate assembly.  It feels like at runtime, it's using the executing assembly to look for the namespace, not the one where the XAML is being parsed from. 

    Is there an additional "assembly" syntax I should be using in the controls project XAML files to make sure all those controls can be found regardless of where we're loaded from?

    My description might be a little cloudy, so here's a concrete example:

    UIProject1, references ControlsProject1, which has 2 controls in it.  UserControl1 and UserControl2.  UserControl1.xaml contains a using statement for, and uses UserControl2.

    When UIProject1\MainPage.xaml uses UserControl1 (has the standard xmlns using statement for UserControl1 namespace, but nothing about it being in another assembly), I get a runtime exception that UserControl1 can't find UserControl2.

    UIProject1\MainPage.xaml can directly create UserControl2, to prove that it's creatable and will show in the UI.

    Thanks in advance for any guidance.

Answers

All Replies

  • Tuesday, October 18, 2011 4:40 PM
    Moderator
     
     

    Hi Volleynerd,
        Can you send me a project with the problem you're describing?  MSmall at Microsoft. 

    Thanks,
    Matt


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
  • Wednesday, October 19, 2011 11:29 PM
     
     

    Hi Matt -

    Just emailed you a zip that shows the problem.  In building the zip, we boiled it down to the following. 

    - Put 2 user controls in a class library separate from the main UI project
    - UserControl1 uses UserControl2 in its XAML definition
    - Make use of UserControl1 in the UI project (MainPage.xaml)
    - Works fine if you only do the above.
    - This sounds crazy but ... add a class to the controls project and have that class implement INotifyPropertyChanged (from UI.Xaml.Data, not System.ComponentModel).  You don't even have to use that class anywhere.

    Run the app. It blows up trying to load UserControl2


    Zip of the code showing the problem:

    https://skydrive.live.com/?cid=777ba681e50112ba&sc=documents&uc=1&id=777BA681E50112BA%21186#

     

  • Friday, October 21, 2011 8:08 PM
    Moderator
     
     Answered
    Hi - this is an already-known bug that we are currently researching.  Thanks for the feedback.
    Matt Small - Microsoft Escalation Engineer - Forum Moderator
  • Sunday, February 19, 2012 4:00 PM
     
     
    Hi, have you found a workaround or a bugfix for this problem? I need this to work in my project...
    • Edited by Rico Suter Sunday, February 19, 2012 4:52 PM
    •