gpt4 book ai didi

c++ - 项目构建失败 : "gcroot.h This document is opened by another project"

转载 作者:行者123 更新时间:2023-11-28 04:52:47 24 4
gpt4 key购买 nike

我正在尝试使用以下教程为 C# 类构建 C++ 包装器: pragmateek C++ wrapper for C# class

当我运行构建时,我得到这个错误:

Error C1001 An internal error has occurred in the compiler. [project name] 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 );
}

我收到多个弹出提示所有阅读:

"This document is opened by another project"


我正在使用 VS2017,.net 4.5

有什么我没有看到的技巧吗?是否有更好或更现代/规范的方法来包装 .net 类以在 C++ 中使用?我的最终目标是使用 C# 进行开发,并使用 C++ 为客户端提供 API。我的客户在项目中走得太远无法回头,然后失去了他们的 C# 人员,现在希望我将我的项目部分切换到 C++。

我已经在谷歌上花费了大量时间。

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

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

最佳答案

我遇到了同样的问题并找到了适合我的解决方案:

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

对比:项目Properties->Configuration properties->General->Configuration Type->Dynamic Link Library (.dll)

解释:我遇到了同样的问题,并将 Project Properties->Configuration properties->C/C++->All Options->Conformance modeYes (/permissive-) 更改为 没有

新构建指示链接器入口点错误:LNK1561 必须定义入口点

快速检查构建配置发现错误的配置类型(exe 而不是 dll)

关于c++ - 项目构建失败 : "gcroot.h This document is opened by another project",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47803607/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com