I'm trying to build a C++ wrapper for a C# class using the following tutorial: pragmateek C++ wrapper for C# class
When I run build, I get this error:
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
When I click on the error it does the following: VS opens gcroot.h to line 110
void swap( gcroot<T> & _right )
{ //VS shows error on this line
using std::swap;
swap( _handle, _right._handle );
}
I get multiple popup prompts all reading:
"This document is opened by another project"
I'm using VS2017, .net 4.5
Is there some trick to this I'm not seeing? Is there a better or more modern/canonical way to wrap a .net class for use in C++? My end-goal is to develop in C# and provide an API for the client in C++. My client got too far into the project to turn back, and then lost their C# guy and now wants me to switch my part of the project to C++.
I've spent a ton of time on google already.
Update: Adding either of the following causes it to throw the error:
#include <vcclr.h>
#include <msclr\auto_gcroot.h>
I had the same issue and found a working solution for me:
Solution: Change your wrapper build from .exe to .dll
VS: Project Properties->Configuration properties->General->Configuration Type->Dynamic Link Library (.dll)
Explained: i had the same issue and changed Project Properties->Configuration properties->C/C++->All Options->Conformance mode
from Yes (/permissive-)
to No
A new build indicated a linker entry-point error: LNK1561
entry point must be defined
A quick check of the build configuration revealed the wrong Configuration Type
(exe instead of dll)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.