all groups > dotnet clr > september 2006 >
You're in the

dotnet clr

group:

overriding C++/CLI Dispose in C#


overriding C++/CLI Dispose in C# John
9/15/2006 1:47:58 PM
dotnet clr:
I'm having a problem trying to override IDisposable.Dispose() in a C#
class that inherits a C++/CLI class that implements Dispose(). The
compiler says

Error 13 'JM.UI2.EditBoxDataModel.Dispose()': cannot override inherited
member 'JM.UI.Base.Dispose()' because it is not marked virtual,
abstract, or override
C:\depot-jmatzen-dell\depot\game14\src\engine\UI2\UIEditBox.cs 19 26 UI2

But in fact, in my base class I have ~Base() declared as virtual (and I
think it's virtual by default anyway but that's beside the point):

virtual ~Base();

Here's my C# class

public class EditBoxDataModel
: Base
{
public override void Dispose()
{
}
};


Re: overriding C++/CLI Dispose in C# Ben Voigt
9/25/2006 11:27:12 AM

[quoted text, click to view]

The compiler is nit picking here. You can't override JM.UI.Base.Dispose.
You can override IDisposable.Dispose.

Just write
public class Sub : Base, IDisposable
{
public void Dispose()
{
}
}


[quoted text, click to view]

AddThis Social Bookmark Button