C++/CLI 不能调C# class 的 Dispose()方法
我有一个C# class 实现了IDisposable接口
在C#里面调用都是没问题的, 但是在c++里调用里出现编译错误:
Error 1 error C2039: 'Dispose' : is not a member of ‘Mathematics::Matrix<T>'
output:
error C2039: 'Dispose' : is not a member of 'InScan::Infrastructure::Common::Mathematics::Matrix<T>'
1> with
1> [
1> T=byte
1> ]
1> You should invoke the destructor, '~Matrix<unsigned char>' instead
所以我现在只能这样:
为什么Dispose()方法在C++里面会调不到?
public class Matrix<T> : IDisposable, ICloneable, IEnumerable<T>
{
...
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
}
在C#里面调用都是没问题的, 但是在c++里调用里出现编译错误:
Error 1 error C2039: 'Dispose' : is not a member of ‘Mathematics::Matrix<T>'
output:
error C2039: 'Dispose' : is not a member of 'InScan::Infrastructure::Common::Mathematics::Matrix<T>'
1> with
1> [
1> T=byte
1> ]
1> You should invoke the destructor, '~Matrix<unsigned char>' instead
所以我现在只能这样:
delete matrix;
GC::Collect();
为什么Dispose()方法在C++里面会调不到?
...全文
相关推荐
C ++ / CLI HowTo:派生自C#一次性类
本文介绍了从可弃用C#库实现C ++ / CLI类的方法。
Visual Studio中C++/CLI项目创建与配置实战指南
C++/CLI是微软推出的混合编程技术,它允许开发者在.NET公共语言运行时(CLR)上运行C++代码,实现托管与非托管代码的互操作。其核心原理是通过/clr编译器开关将C++代码编译为托管中间语言(IL)和原生代码的混合体,在保留C++底层控制能力的同时,无缝调用.NET框架的丰富类库。这项技术的价值在于能够桥接高性能原生C++模块与现代化的C#应用程序,特别适用于需要将遗留C++代码集成到WPF、WinForms等.NET桌面应用中的场景。在Visual Studio中配置C++/CLI项目时,需注意正
面试题(.NET)答案
最全.NET面试题目和答案! 有C#的一些题目,ADO的一些题目 很全的!
C#的内存管理:堆、栈、托管堆与指针
堆、栈、托管堆与指针的内存管理,有谁知道,还不赶快下载
超图8CiObjects 入门教程
超图8CiObjects 入门教程


