问题描述
我的项目设置如下:
- CustomControls - Windows运行时组件。这有一个Custom ButtonControl,它基于Button。控件的名称是CustomButton。使用命名空间引用将CustomButton.xaml类中的TargetType设置为CustomButton。
- CustomLibrary - 使用WINRT API的静态库组件。这包括CustomControls作为参考,并在其CustomLibrary.cpp类中使用CustomButton。
- TestApp - 包含CustomLibrary作为参考的Windows运行时应用程序,并在其MainPage.xaml中使用CustomLibrary.cpp类.cpp class。
如果我尝试启动TestApp它只是崩溃:
WinRT信息:无法反序列化XBF元数据类型列表,因为在命名空间"CustomControls"中找不到"CustomButton"。 [行:0位置:0]
如果我删除CustomButton类中引用的命名空间并将TargetType设置为Button,则可以正常工作。
基于上面的scneario ,我假设UWP正在尝试对命名空间进行运行时解引用。如果我直接在TestApp中包含CustomControls,那么命名空间问题就不存在了。但是如果中间有一个额外的组件,
这是失败的。
我已经在这里上传了设置: https://1drv.ms/u/s!AhgimvNrj16ugfNggKWNwTFdbta0tQ
我需要这种结构。那么我在这里错过了什么以及我可以做些什么来解决这个问题?
Hi,
I have a project set up as follows :
- CustomControls - A Windows Runtime Component. This has a Custom UserControl which is based out of Button. The name of the control is CustomButton. The TargetType in the CustomButton.xaml class is set to CustomButton using namespace referencing.
- CustomLibrary - A Static Library component which consumes WINRT APIs. This includes CustomControls as reference and makes use of the CustomButton in it's CustomLibrary.cpp class.
- TestApp - A Windows Runtime App which includes CustomLibrary as reference and makes use of the CustomLibrary.cpp class in it's MainPage.xaml.cpp class.
If I try to launch the TestApp it simply crashes :
WinRT information: Cannot deserialize XBF metadata type list as 'CustomButton' was not found in namespace 'CustomControls'. [Line: 0 Position: 0]
If I remove the namespace referencing in the CustomButton class and set the TargetType to Button , this works.
Based on the above scneario , I am assuming that UWP is trying to do a runtime de-referencing of the namespace. If I directly include CustomControls in the TestApp , the namespace issue is not there. But in case of an extra component in between, this is failing.
I have uploaded the setup here : https://1drv.ms/u/s!AhgimvNrj16ugfNggKWNwTFdbta0tQ
I need this structure. So what am I missing here and what I can do to resolve this ?
这篇关于[UWP] [C ++]无法定义Custom UserControl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!