【发布时间】:2021-09-11 00:40:30
【问题描述】:
使用 Visual Studio 2019 16.10.2 如何在 C++/WinRT 控制台程序中包含 .NET 组件?
The indexOf 方法 of IVector 需要来自 System 的 a UInt32 struct。
System 在这种情况下如何使用?尝试使用命名空间会导致
"System' : a namespace with this name does not exist"
This has been covered already on SO,但仅适用于 C++/CLI 应用程序,不适用于 C++/WinRT 控制台应用程序的上下文。该帖子中提供的解决方案也不起作用。
#include "pch.h"
#include <Windows.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
using winrt::Windows::Foundation::Collections::IVector;
using namespace System;
int main()
{
IVector<int> foo;
foo.Append(1);
UInt32 bar;
foo.indexOf(1, bar);
return EXIT_SUCCESS;
}
在这种情况下,pch.h 为空。
【问题讨论】:
标签: c++ .net visual-studio windows-runtime c++-winrt