C++ 'System' : 具有此名称的命名空间不存在

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16732789/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 20:35:52  来源:igfitidea点击:

'System' : a namespace with this name does not exist

c++wpfbuild-error

提问by Narendra

I had a C++ project which was running perfectly. Now I copied the project to another folder and added the project to a WPF application solution.

我有一个运行完美的 C++ 项目。现在我将项目复制到另一个文件夹并将项目添加到 WPF 应用程序解决方案。

Now the C++ project is giving me lot of build errors. One of them is "System' : a namespace with this name does not exist".

现在 C++ 项目给了我很多构建错误。其中之一是"System' : a namespace with this name does not exist"

Below are the lines which creates this error.

以下是产生此错误的行。

#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;

The above lines are in AssemblyInfo.cppfile. I don't have any experience of C++, so finding it difficult to remove the errors. Any help is appreciated. Below is another error which might be helpful for you to resolve the issue.

以上几行在AssemblyInfo.cpp文件中。我没有任何 C++ 经验,因此发现很难消除错误。任何帮助表示赞赏。下面是另一个错误,可能有助于您解决问题。

managed targeted code requires a '/clr' option

Thanks in advance.

提前致谢。

回答by Mif

Set Common Language RunTime Support to be "Common Language RunTime Support (/clr)" in 2places in your project properties :

在项目属性的2 个地方将公共语言运行时支持设置为“公共语言运行时支持 (/clr)” :

Configuration Properties -> General

配置属性 -> 常规

Configuration Properties -> C/C++ -> General

配置属性 -> C/C++ -> 常规