Interface inheritance?

  • Thread starter Thread starter Mark Essex
  • Start date Start date
M

Mark Essex

Am I correct that I can't do Interface Inheritance in C#?

What I was trying to do is have one interface (which was part of my
framework) and then have the application-specific interface inherit from
this interface and extend it as needed. I thought my application would only
need a reference to the application-specific interface (different assembly)
and that the application would have a reference to the framework-specific
interface (again, different assembly). Something like the following:

Client App ---> references Application assembly (with application
interface) --> which references Framework Assembly (with framework
interface)

ex.

Framework Interface:
public interface IRemoteObject

{

DataSet GetData();

DataSet SaveData(DataSet dataSet);

}


App-specific interface:

public interface IMethRemoteObject : IRemoteObject

{

DataSet GetPatientData();

}

However, the Client App can't see the framework interface unless I put a
reference in the CLient App to the Framework Assembly.


I guess the proper way to handle this is to put a reference to both
interfaces, and not inherit one interface from another.

I just want to make sure I am understanding what is going on (or not going
on in this case).

Thanks,
Mark
 
Mark Essex said:
Am I correct that I can't do Interface Inheritance in C#?

What I was trying to do is have one interface (which was part of my
framework) and then have the application-specific interface inherit from
this interface and extend it as needed. I thought my application would only
need a reference to the application-specific interface (different assembly)
and that the application would have a reference to the framework-specific
interface (again, different assembly). Something like the following:

Client App ---> references Application assembly (with application
interface) --> which references Framework Assembly (with framework
interface)

ex.

Framework Interface:
public interface IRemoteObject

{

DataSet GetData();

DataSet SaveData(DataSet dataSet);

}


App-specific interface:

public interface IMethRemoteObject : IRemoteObject

{

DataSet GetPatientData();

}

However, the Client App can't see the framework interface unless I put a
reference in the CLient App to the Framework Assembly.


I guess the proper way to handle this is to put a reference to both
interfaces, and not inherit one interface from another.

I just want to make sure I am understanding what is going on (or not going
on in this case).

You can do interface inheritance, but you still need to reference both
assemblies.
 
Mark Essex said:
Am I correct that I can't do Interface Inheritance in C#?
No.

What I was trying to do is have one interface (which was part of my
framework) and then have the application-specific interface inherit from
this interface and extend it as needed. I thought my application would only
need a reference to the application-specific interface (different assembly)
and that the application would have a reference to the framework-specific
interface (again, different assembly). Something like the following:

<snip>

That's got nothing to do with inheritance - it's just that you need to
reference *all* the appropriate assemblies in a sort of recursive
manner. So long as you reference both of the assemblies in question,
there should be no problem with one interface inheriting from another.
 
Back
Top