我有一个运行良好的 C++ 项目。现在我将项目复制到另一个文件夹并将项目添加到 WPF 应用程序解决方案中。
现在 C++ 项目给了我很多构建错误。其中之一是 "System' : a namespace with this name does not exist"
。
以下是产生此错误的行。
#include "stdafx.h"
using namespace System;
using namespace System::Reflection;
using namespace System::Runtime::CompilerServices;
using namespace System::Runtime::InteropServices;
using namespace System::Security::Permissions;
以上行在 AssemblyInfo.cpp 文件中。我没有任何 C++ 经验,因此很难消除错误。任何帮助表示赞赏。下面是另一个可能有助于您解决问题的错误。
managed targeted code requires a '/clr' option
提前致谢。
原文由 Narendra 发布,翻译遵循 CC BY-SA 4.0 许可协议
在项目属性的 2 个 位置将公共语言运行时支持设置为“公共语言运行时支持 (/clr)”:
对于 2019 年之前的 Visual Studio:
对于 Visual Studio 2019: