I use PEVerify on the assemblies I'm developing. One particular assembly
fails with the following error:
[MD]: Error: Class implements interface but not method (class:0x02000032;
interface:0x02000031; method:0x060001b2).0x09000013]
Here's the situation boiled down to the essentials:
public interface IMyInterface
{
System.Drawing.Color BackColor {get;set;}
.
.
.
}
public class MyControl : System.Windows.Forms.UserControl, IMyInterface
{
.
.
.
}
It turns out that although MyControl does not implement the interface
methods (get_BackColor, set_BackColor), an ancestor class does (Control). I
don't understand why PEVerify reports this as an error.
The CLR loads and executes the assembly fine so it seems to be passing
runtime verification.
Hi Andrew,
There is neither compilation nor runtime error because a class in the chain
of base classes of MyControl, namely System.Windows.Forms.Control, has
exactly the same BackColor property as IMyInterface has. The interface
mapping process locates this property and assumes that it is the
implementation of IMyInterface.BackColor. This link to C# specification
gives more information on interface mapping:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csspec/html/vcl
rfcsharpspec_13_4_2.asp
PEVerify simply says that
MyControl wants to implement IMyInterface (because it is in the list of
its interfaces)
MyControl does not implement IMyInterface (probably by mistake)
One of the base classes of MyControl already implements all
properties/methods of IMyInterface
You can get rid of the error by making MyControl an abstract class. This
will tell PEVerify that MyControl does not implement IMyInterface
intentionally.
Thanks,
Yuri
>I use PEVerify on the assemblies I'm developing. One particular assembly
> fails with the following error:
[quoted text clipped - 26 lines]
> The CLR loads and executes the assembly fine so it seems to be passing
> runtime verification.
AndrewP - 19 Nov 2004 15:19 GMT
Thanks yuri.
However, it still seems a little odd to me that peverify considers this an
"error" and not something less severe, like a "warning". After all, the
interface mapping of the 'IMyInterface.BackColor' member to the base Control
class doesn't violate type safety, does it? If it doesn't (and I don't
believe it does), then peverify should be passing the assembly, not failing
it -- At least according to the stated purpose of the peverify tool.
> Hi Andrew,
>
[quoted text clipped - 51 lines]
> > The CLR loads and executes the assembly fine so it seems to be passing
> > runtime verification.