XAML cannot find reference in local namespace

前端 未结 2 767
闹比i
闹比i 2020-12-11 03:31

I created a new Metro Split App in C++ using VS2012 on Win8 (both RC). Everything compiled and worked out of the box. I then changed went through and changed the generated n

相关标签:
2条回答
  • 2020-12-11 03:43

    I had a similar bug, but then I closed VS, deleted the .suo, and reloaded the project and everything worked just fine.

    0 讨论(0)
  • 2020-12-11 03:51

    The name of the WinMD file produced by your project must be some prefix of the namespaces in which the public WinRT types are defined. Given that your type is in the A.B.Product.Client.Common namespace , the WinMD file must have one of the following names:

    A.winmd
    A.B.winmd
    A.B.Product.winmd
    A.B.Product.Client.winmd
    A.B.Product.Client.Common.winmd
    

    The public types must also be defined in the WinMD file with the longest prefix that matches the namespace. So, if you have both A.winmd and A.B.winmd, the type A.B.MyClass must be defined in A.B.winmd.

    So, why does your code work at runtime but not in the designer? The naming rules for public types only apply to types defined in Windows Runtime components (for C++, DLL files), not for applications (EXEs).

    However, to be able to instantiate your user-defined types (including LayoutAwarePage), the designer will load your project's EXE as a DLL, so the naming rules must be followed.

    0 讨论(0)
提交回复
热议问题