471,350 Members | 1,674 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

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

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

Aug 4 '08 #1
3 15605
Jon E <Jo**@discussions.microsoft.comwrote:

<snip>
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?

--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Aug 4 '08 #2
On Aug 4, 9:50*am, Jon E <J...@discussions.microsoft.comwrote:
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)
Aug 4 '08 #3
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

On Aug 4, 10:18*am, "Ignacio Machin ( .NET/ C# MVP )"
<ignacio.mac...@gmail.comwrote:
On Aug 4, 9:50*am, Jon E <J...@discussions.microsoft.comwrote:
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)
Aug 6 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by seesaw | last post: by
2 posts views Thread by Bill Zhao | last post: by
39 posts views Thread by utab | last post: by
6 posts views Thread by Smithers | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.