"does not implement interface member" Error - Known bug ?

J

Jon E

I have an interface class with maybe eight functions, defined in one
workspace and am defining a class in a second workspace that derives from
this interface.

Unfortunately only 7 of the 8 functions in my derived class compile whilst
just one of them refuses to be recognised, leading to an error message
"...does not implement interface member...".

Try as I might, I can't fix the error. I have cut and paste names so can
rule out simple type errors.

If I cut and paste the interface class into the second workspace (just
renaming interface so it doesn't clash) then behold, now it works !

The only thing that differentiates the one function that fails from the
other 7 is that one of the parameters is an enum defined in the first
workspace.

Have I missed something obvious ? Or is this a bug in VS2005 ?

I can get it to compile by fully qualifying everything:-

Original :-

public bool MyFunc( EnumedType x, int y )

Modified. :-

bool firstnamespace.IMyInterface.MyFunc( firstnamespace.EnumedType x, int y)

Note however that I've had to remove the "public" from the modified form :-(
Totally confused (yes, I have the "using firstnamespace;" at teh top of teh
file and I have added the first namespace to teh project's references.

TTFN,
Jon
 
J

Jon Skeet [C# MVP]

Original :-

public bool MyFunc( EnumedType x, int y )

Modified. :-

bool firstnamespace.IMyInterface.MyFunc( firstnamespace.EnumedType x, int y)

Note however that I've had to remove the "public" from the modified form :-(
Totally confused (yes, I have the "using firstnamespace;" at teh top of teh
file and I have added the first namespace to teh project's references.

The reason you have to remove the public there is that it's now
explicitly implementing that part of the interface.

However, it's not clear why it wasn't working beforehand. Can you post
a short but complete example (in two projects still) which shows the
problem?
 
I

Ignacio Machin ( .NET/ C# MVP )

I have an interface class with maybe eight functions, defined in one
workspace and am defining a class in a second workspace that derives from
this interface.

a class IMPLEMENT an interface, does not derives from it.

Have I missed something obvious ? Or is this a bug in VS2005 ?

not sure of where your error is, I would guess (and this is only a
guess) that some of the parameters types have a name conflict with
some other types defined in your second namespace.

What I usually do is using the autogeneration feature of the IDE,
when you implement an interface you can autogenerate the members ( by
click shift+alt+F10)
 
K

kyle.szklenski

I agree with this advice.

I tried to reproduce this and could not. Here is the method I went
about that:

1) Create a new project workspace - project1
2) Create a new project within the workspace - project2
3) Add an interface file to project2
4) Add an enum to the interface file inside the namespace
5) Make the interface have several functions, one of which takes the
enum
6) Make project1 have a reference to project2 and add the using
namespace call
7) In project1, make a class which implements the interface
8) Right-click the interface name and click "Implement Interface"
9) Finally, compile it.

Did I miss something important?

Kyle
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top