Class interface sharing

F

fujiyama

Hi,
I have a problem with reuse of the same class interface.
I have two user controls which uses the same IAppElement interface.
When I use both controls I recieve warning message warning CS0436 -
because the same interfaces is defined in two assemblies with the same
name/namespace.

I know that I can avoid this using additional assembly for both
controls but I'm looking different solution with give me ability to
reuse imported definition.


Regards
Mikolaj
 
J

Jon Skeet [C# MVP]

I have a problem with reuse of the same class interface.
I have two user controls which uses the same IAppElement interface.
When I use both controls I recieve warning message warning CS0436 -
because the same interfaces is defined in two assemblies with the same
name/namespace.

I know that I can avoid this using additional assembly for both
controls but I'm looking different solution with give me ability to
reuse imported definition.

With C# 2.0 you *can* use extern aliases to do this - but I really
wouldn't. You'd have to use the correct alias each time. Note that even
though the types have the same name and the same members, they are
currently different types as far as the computer is concerned.

You really should put them into a common assembly - it's the right way
of doing things.

Jon
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Did you do the two controls?

If so you should read the plug-in article of Jon's at
http://www.yoda.arachsys.com/csharp/plugin.html , basically you need to
define the interface ONCE and reference it from all other possible
projects/namespace .

It's common to define it in the same project where you define your "base"
or default implementation, this avoid you the overload of having a separate
project just for the interfaces.
 

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