如何从用C#编写的Windows运行时组件中将UserControl导入C ++ / WinRT项目?

时间:2019-01-23 15:37:39

标签: windows-runtime winrt-xaml c++-winrt

我在解决方案中有一个非常简单的用C#编写的Windows运行时组件项目,在其中我添加了一个要导出到C ++ / WinRT项目的UserControl。 当导入到另一个C#项目中时,此组件可以正常工作,但是当我尝试在我的C ++ / WinRT项目中导入并使用它时,出现编译错误。

\my_project\generated files\xamltypeinfo.g.cpp(1313): error C3083: 'my_component_XamlTypeInfo': the symbol to the left of a '::' must be a type

我添加了对该组件的引用,并在我的pch.h中添加了以下包含,以为它可以解决该问题:

#include "winrt/my_component.h"

但随后出现以下编译错误:

\my_project\generated files\xamltypeinfo.g.cpp(1306): error C3083: 'my_component_XamlTypeInfo': the symbol to the left of a '::' must be a type

我注意到,如果包含标头,还会有: #include "winrt/data_grid.data_grid_XamlTypeInfo.h"

我不再遇到编译器错误,但是在尝试实例化组件时,应用程序在启动时崩溃。

将包含XAML的Windows运行时组件导入C ++ / WinRT应用程序的正常过程是什么?

0 个答案:

没有答案