IBatis: "Unable to cast object of type 'Castle.Proxies.IDaoProxy' to type 'SysProt.Dao.ICustomerDao'."
- by j_maly
I am trying to set up IBatis.NET.
I have downloaded the sources from http://mybatisnet.googlecode.com/svn/branches/ibatis-1-maintenance/src.
This is my initialization
DomDaoManagerBuilder builder = new DomDaoManagerBuilder();
builder.Configure("dao.config");
IDaoManager daoManager = DaoManager.GetInstance("SqlMapDao");
customerDao = daoManager[typeof(ICustomerDao)];
ICustomerDao cd = (ICustomerDao) customerDao;
The last line throws InvalidCastException "Unable to cast object of type 'Castle.Proxies.IDaoProxy' to type 'SysProt.Dao.ICustomerDao'."
I am not sure, what I did wrong, my dao.config files contains
Here are the definitions of the classes/interfaces:
public interface ICustomerDao
{
Customer Load(long id);
}
public class CustomerDao: BaseDao, ICustomerDao
{
public Customer Load(long id)
{
throw new NotImplementedException();
}
}
public class BaseDao : IDao
{
protected DaoSession GetContext()
{
IDaoManager daoManager = DaoManager.GetInstance(this);
return (daoManager.LocalDaoSession as DaoSession);
}
}