Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/163.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
项目未能生成:“;gcroot.h此文档由另一个项目“打开”; 我试图用下面的教程为C++类构建C++包装: _C++_Build_Compiler Errors_Visual Studio 2017_Wrapper - Fatal编程技术网

项目未能生成:“;gcroot.h此文档由另一个项目“打开”; 我试图用下面的教程为C++类构建C++包装:

项目未能生成:“;gcroot.h此文档由另一个项目“打开”; 我试图用下面的教程为C++类构建C++包装: ,c++,build,compiler-errors,visual-studio-2017,wrapper,C++,Build,Compiler Errors,Visual Studio 2017,Wrapper,运行生成时,出现以下错误: 错误C1001编译器中发生内部错误。[项目名称]C:\Program Files(x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.12.25827\include\msclr\gcroot.h 110 单击错误时,它会执行以下操作: VS打开gcroot.h至第110行 void swap( gcroot<T> & _right ) { //VS shows err

运行生成时,出现以下错误:

错误C1001编译器中发生内部错误。[项目名称]C:\Program Files(x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.12.25827\include\msclr\gcroot.h 110

单击错误时,它会执行以下操作: VS打开gcroot.h至第110行

void swap( gcroot<T> & _right )
    { //VS shows error on this line
            using std::swap;
            swap( _handle, _right._handle );
    }
void swap(gcroot&右)
{//VS在此行上显示错误
使用std::swap;
交换(_handle,_right._handle);
}
我收到多个弹出提示,所有内容如下:

“此文档已由另一个项目打开”


我正在使用VS2017、.net 4.5

有什么我没看到的把戏吗?是否有更好的或更现代的/规范的方式来包装.NET类以供C++使用?我的最终目标是在C语言中开发,并为C++中的客户端提供API。我的客户太投入这个项目了,然后失去了他们的C,现在我想把我的项目转到C++。p> 我已经在谷歌上花了很多时间

更新: 添加以下任一项会导致抛出错误:

#include <vcclr.h>
#include <msclr\auto_gcroot.h>
#包括
#包括

我也遇到了同样的问题,并找到了一个可行的解决方案:

解决方案: 将包装器生成从.exe更改为.dll

VS: 项目
属性->配置属性->常规->配置类型->动态链接库(.dll)

解释: 我遇到了同样的问题,并将
项目属性->配置属性->C/C++->所有选项->一致性模式
是(/permissive-
更改为

新生成表明链接器入口点错误:
LNK1561
必须定义入口点


快速检查生成配置发现配置类型错误(exe而不是dll)

我是gcroot。很抱歉我不得不这么做。这也是真的!长版本:我忘了在我的测试项目上这样做,并设置了链接,使得依赖包装器类使用DLL的“发布”版本,因此由于我没有为发布构建,更改没有反馈。