Friday, February 1, 2008

What the heck?

Anyone know what a _VbtlGapX_Y method is?

Some strange behavior here...we have a COM interface (from the same type library as the other) which we're implementing. All properties and methods of the interface are completely implemented, but on compile I'm getting four errors:

[Class Signature] does not implement interface member [Interface]._VtblGap8_2()
[Class Signature] does not implement interface member [Interface]._VtblGap11_2()
[Class Signature] does not implement interface member [Interface]._VtblGap26_2()
[Class Signature] does not implement interface member [Interface]._VtblGap171_2()


Its a rather ugly thing to try and search; exact searches for _VbtlGap8_2 give nothing at all.

Based on some googling and a little bit of guesswork, it seems that VTables are part of the COM-Interop system, and should normally be hidden in .Net. Its anyone's guess why that's not the case here.

Fortunately, I did find a solution...Bite the bullet and implement them:

public void _VtblGap8_2()
{
throw new Exception("Don't access this method");
}


Why a public method and not an explicit implementation? Because it doesn't work...it was the first thing I tried. Unfortunately, while that DOES compile, any attempt to instantiate the class will fail, throwing a Type exception. Public implementation was the only way I found to successfully compile and use the object, even if it means they are visible (and ugly) public methods on the class.

Anyone know of a better solution?