1. 同时使用C++操作符new和MC++操作符new

使用__gc和__nogc关键字:
例如,托管类M和本地类N
M* m = __gc new M;
N* n = __nogc new N;

2. 含有析构函数定义的托管派生类链接时错误:
error LNK2001: unresolved external symbol "void __cdecl __CxxCallUnwindDtor(void (__thiscall*)(void *),void *)" (?__CxxCallUnwindDtor@@$$J0YAXP6EXPAX@Z0@Z)

解决方案:
1、在项目中显式引用msvcrt.lib或者msvcrtd.lib,具体做法是在头文件中增加一行
MC++ tips#pragma comment( lib, "msvcrt" ) // 或msvcrtd

2、如果不需要exception unwinding,可以取消对C++ Exception的支持,具体做法(以vs2003为例):
项目属性 -> C/C++ -> Code Generation -> Enable C++ Exceptions
注:/EHsc选项同样可以解决STL等需要支持C++ Exceptions的库的连接错误问题

3. 没有显示引入dll造成的TypeLoadException
例如
MC++ tips// 在头文件中
MC++ tips
public __gc class ImageProvider
}
上述代码可以通过编译,但是可能会在运行时引发TypeLoadException异常。
解决方案是在头文件中使用#using指令引入System.Drawing.dll
MC++ tips#using <system.drawing.dll>



相关文章:

  • 2021-09-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-30
  • 2022-12-23
  • 2022-12-23
  • 2021-06-22
猜你喜欢
  • 2021-09-03
  • 2022-12-23
  • 2022-12-23
  • 2021-07-10
  • 2021-08-17
  • 2022-12-23
相关资源
相似解决方案