Hi there,
can anyone help, i have a small issue, i have an interface and also a base interface, when i try to do
.Dispose()
It doesn't find the method as its implemented on my sub class NOT base.. and it always seems to want to call the base - even though i specifically put the namespace in front of the parameter on the constructor.
Here is some code to explain it better, basically there are 2 IhouseRepository (interfaces), 1 is the base interface and one is the subclass interface.
In the constructor i have specifically said its MarkSmith.Data (and not MarkSmith.DataBase) but it keeps pickup up the DataBase version where Dispose is not implemented.
My idea was to implement IDisposable in all subclasses and should be there responsibility to dispose.
In the constructor i have a put a single line that calls the IhouseRepository and i "CAN" access Dispose - so it does work - Why it works here on not on the param passed to the constructor is a mystery :-)
But the param on the constructor seems to be forcing the namespace DataBase and not Data
I suppose i could rename all my Interfaces on the base project to IHouseRepositoryBase but i don't understand why this is happening.
Any help really appreciated
public class HouseService : ServiceBase.HouseService, IHouseService
{
public HouseService(MarkSmith.Data.IHouseRepository repository)
: base(repository)
{
MarkSmith.Data.IHouseRepository test =
new MarkSmith.Data.HouseRepository(new MyDataContext);
test.Dispose(); // THIS WORKS! NO PROBLEMS
}
// Dispose() calls Dispose(true)
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
// free managed resources
if (repository != null)
{
repository.Dispose(); // THIS FAILS .. IT IS CALLING NS DATABASE
}
}