Welcome to Atalasoft Community Sign in | Help

Managed C++ and IDisposable

I'm writing some code using the new Managed C++/CLI syntax and I ran into this error:

error C2039: 'Dispose' : is not a member of 'System::IDisposable'

the code I started with was this:

image->Dispose(); // image implements IDisposable

which gave me the same compiler error, so I wanted to eliminate a class/namespace error so I rewrote it as this:

((IDisposable ^)image)->Dispose();

Which gave the above error.  Yikes!

Here's the fix:

use delete.  Managed C++ now hides Dispose() inside the finalizer.  Just delete the object, it handles the rest. Freaky.

Published Friday, August 01, 2008 9:40 AM by Steve Hawley

Comments

Wednesday, August 06, 2008 11:45 PM by DotNetKicks.com

# Managed C and IDisposable

You've been kicked (a good thing) - Trackback from DotNetKicks.com

Thursday, February 27, 2014 4:07 PM by High CPU Usage

# High CPU Usage

High CPU Usage Fixer can also speed up your computer performance, deal with specific technical areas of your computer system, safeguarding them from unwanted errors or manipulating your system to let your computer operate on its full abilities.

Anonymous comments are disabled