Issue in compiling with marshal.h : error C2872: 'IServiceProvider' : ambiguous symbol

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 22:09:56

You do, indirectly, marshal.h includes it. It dumps an enormous amount of identifiers in the global namespace. The macros are especially awkward, lots of them match names used in the framework.

Lots of things that marshal.h does can be done by the Marshal class as well. But I can't help you with that, you didn't mention why you want to use it. You can solve this particular mishap by putting the #include directive before the using statements:

#include <msclr/marshal.h>
using namespace System;
using namespace System::Configuration;

Make sure you only have the:

using namespace System;

in the cpp file of the CLR project and not in the header. Visual studio automatically adds it to the header when creating a CLR class library project. In the cpp itself, the includes must precede the "using namespace".

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!